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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main() {
   unsigned int h1, h2, w1, w2;
   unsigned int min_h, max_h, min_w, max_w;
   bool good;
   char test;

   int t, n, t1, n1;
   scanf("%d", &t);


   for (t1=0; t1 < t; t1++) {
      scanf("%d", &n);
      max_w = max_h = 0;
      min_w = min_h = 1000000001;

      good = false;

      for (n1=0; n1 < n; n1++) {
         test = 0;

         scanf("%u %u %u %u", &w1, &w2, &h1, &h2);

         if (w1 > min_w) {
            test += 4;
         } else if (w1 < min_w) {
            min_w = w1;
            test += -1;
            good = false;
         }
         if (w2 < max_w) {
            test += 4;
         } else if (w2 > max_w) {
            max_w = w2;
            test += -1;
            good = false;
         }

         if (h1 > min_h) {
            test += 4;
         } else if (h1 < min_h) {
            min_h = h1;
            test += -1;
            good = false;
         }
         if (h2 < max_h) {
            test += 4;
         } else if (h2 > max_h) {
            max_h = h2;
            test += -1;
            good = false;
         }

         if (test < 0) good = true;

      }
      if (good == true) {
         printf("TAK\n");
      } else {
         printf("NIE\n");
      }
   }


   return 0;
}