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 <stdio.h>

int main(void){
  int t,n,i;
  int minH,maxH,minW,maxW;
  int h1[100001];
  int h2[100001];
  int w1[100001];
  int w2[100001];

  scanf("%d",&t);
  while(t--){
    int ok=0;
    scanf("%d",&n);

    minH=minW=2000000000;
    maxH=maxW=0;
    for(i=0;i<n;i++){
       scanf("%d%d%d%d",h1+i,h2+i,w1+i,w2+i);
       if(minH>h1[i])minH=h1[i];
       if(maxH<h2[i])maxH=h2[i];
       if(minW>w1[i])minW=w1[i];
       if(maxW<w2[i])maxW=w2[i];

    }
    for(i=0;i<n;i++){
       if( (h1[i]==minH) && (h2[i]==maxH) && (w1[i]==minW) && (w2[i]==maxW) )ok=1;
    }
    if(ok) printf("TAK\n");
    else printf("NIE\n");
  }
  return 0;
}