1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    #include<cstdio>
    int min(int a, int b){
    if(a>b)return b;
    else return a;
    }
    int max(int a, int b){
    if(a<b)return b;
    else return a;
    }
    int minh[100010], minw[100010], maxh[100010],maxw[100010];
    int main(){
    int t,n,minhh,minww,maxhh,maxww;
    scanf("%d",&t);
    while(t--){
    scanf("%d",&n);
    minhh = 1000000010;
    minww = 1000000010;
    maxhh=-1;
    maxww=-1;
    for(int i = 0; i<n; ++i){
    scanf("%d%d%d%d",&minh[i],&maxh[i],&minw[i],&maxw[i]);
    minhh=min(minhh,minh[i]);
    minww=min(minww,minw[i]);
    maxhh=max(maxhh,maxh[i]);
    maxww=max(maxww,maxw[i]);	
    }
    for(int i = 0; i<n; ++i){
    if(minh[i]==minhh && maxw[i]==maxww && minw[i]==minww && maxh[i]==maxhh){printf("TAK\n");break;}
    else if(i==n-1)printf("NIE\n");
    }
    }
    return 0;
    }