1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
int main(){
        long t,n,w1,w2,h1,h2,wmin,wmax,hmin,hmax;
        char major;
        scanf("%d\n",&t);
        while(t--!=0){
                scanf("%d\n",&n);
                hmin = wmin = 1000000001; hmax = wmax = -1;
                while(n--!=0){
                        scanf("%d %d %d %d\n",&w1,&w2,&h1,&h2);
                        if(w1>=wmin && w2 <=wmax && h1>=hmin && h2<=hmax){
                                ;
                        }else{
                                major = 1;
                                if(w1<=wmin) wmin=w1;else major=0;
                                if(w2>=wmax) wmax=w2;else major=0;
                                if(h1<=hmin) hmin=h1;else major=0;
                                if(h2>=hmax) hmax=h2;else major=0;
                        }
                }
                if(major)printf("TAK\n");else printf("NIE\n");
        }
        return 0;
}