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
#include<cstdio>
#include<climits>

int main(){
    int z; scanf("%d", &z);
    while (z--){
        int n; scanf("%d", &n);
        int maxW = INT_MIN;
        int minW = INT_MAX;
        int maxH = INT_MIN;
        int minH = INT_MAX;
        int ok = 0;
        for (int i=0; i<n; ++i){
            int a, b, c, d;
            int zmiana = 0;
            scanf("%d %d %d %d", &a, &b, &c, &d);
            if (a < minW){
                minW = a;
                zmiana = 1;
            }
            if (b > maxW){
                maxW = b;
                zmiana = 1;
            }
            if (c < minH){
                minH = c;
                zmiana = 1;
            }
            if (d > maxH){
                maxH = d;
                zmiana = 1;
            }
            if (a == minW && b == maxW && c == minH && d == maxH){
                ok = 1;
            }else if (zmiana == 1){
                ok = 0;
            }
        }
        if (ok){
            printf("TAK\n");
        }else{
            printf("NIE\n");
        }
    }
    return 0;
}