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
35
36
37
#include <cstdio>

int sizes[400000];

int main()
{
   int t, n;
   scanf("%d", &t);
   for(int i=1; i<=t; i++)
   {
      int min_w=1000000000, min_h=1000000000, max_w=1, max_h=1;
      scanf("%d", &n);
      for(int j=0; j<n; j++)
      {
         int min_w_idx=4*j, max_w_idx=4*j+1, min_h_idx=4*j+2, max_h_idx=4*j+3;
         scanf("%d", &sizes[min_w_idx]);
	 if(sizes[min_w_idx] < min_w) min_w = sizes[min_w_idx];
	 scanf("%d", &sizes[max_w_idx]);
	 if(sizes[max_w_idx] > max_w) max_w = sizes[max_w_idx];
	 scanf("%d", &sizes[min_h_idx]);
	 if(sizes[min_h_idx] < min_h) min_h = sizes[min_h_idx];
	 scanf("%d", &sizes[max_h_idx]);
	 if(sizes[max_h_idx] > max_h) max_h = sizes[max_h_idx];
      }
      bool major = false;
      for(int j=0; j<n; j++)
         if(sizes[4*j] == min_w && sizes[4*j+1] == max_w && sizes[4*j+2] == min_h && sizes[4*j+3] == max_h)
	 {
	    major = true;
	    printf("TAK\n");
	    break;
	 }
      if(!major)
         printf("NIE\n");	 
   }
   return 0;
}