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>

main(){

       int n,t,i;
       int amin,amax,bmin,bmax;
       bool flag=true;
       int a1[100001],a2[100001],a3[100001],a4[100001];
       scanf("%d",&t);
       while(t--){
                  scanf("%d",&n);
                  scanf("%d%d%d%d",&amin,&amax,&bmin,&bmax);
                  a1[0]=amin;a2[0]=amax;a3[0]=bmin;a4[0]=bmax;
                  for(i=1;i<n;i++){
                      scanf("%d%d%d%d",&a1[i],&a2[i],&a3[i],&a4[i]);
                      amin = a1[i]<amin?a1[i]:amin;
                      amax = a2[i]>amax?a2[i]:amax;
                      bmin = a3[i]<bmin?a3[i]:bmin;
                      bmax = a4[i]>bmax?a4[i]:bmax;
                  }           
                  flag=true;
                  for(i=0;i<n;i++)
                       if((a1[i]==amin) && (a2[i]==amax) && (a3[i]==bmin) && (a4[i]==bmax))  {
                                        flag=false;
                                        printf("TAK\n");
                                        break;
                       }       
                       if(flag)
                                        printf("NIE\n");
                  
       }       
       
}