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
34
#include <stdio.h>

int main(void)
{
 int i=0,j,t,n;
 int w1,w2,h1,h2;
 int mw1,mw2,mh1,mh2;
 int jest=0;
 //int jw1,jw2,jh1,jh2;
 scanf("%d",&t);
 for(;i<t;++i)
 {
  scanf("%d",&n);
  scanf("%d %d %d %d",&w1,&w2,&h1,&h2);
  mw1=w1;mw2=w2;mh1=h1;mh2=h2;
  //jw1=w1;jw2=w2;jh1=h1;jh2=h2;
  jest=1;
  --n;
  for(j=0;j<n;++j)
  {
   scanf("%d %d %d %d",&w1,&w2,&h1,&h2);
   if(mw1>w1){mw1=w1;jest=0;}
   if(mh1>h1){mh1=h1;jest=0;}
   if(mw2<w2){mw2=w2;jest=0;}
   if(mh2<h2){mh2=h2;jest=0;}
   if(mw1==w1 && mw2==w2 && mh1==h1 && mh2==h2)
   {
    jest=1;
   }
  }
  printf(jest?"TAK\n":"NIE\n");
 }
 return 0;
}