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

enum {
    MAX = 100010,
    TOO_MUCH = 2000000000
};

int w1[MAX], w2[MAX], h1[MAX], h2[MAX];

int main()
{
    int t; scanf("%d", &t);
    for(int ii = 0; ii < t; ii++)
    {
        int w_min = TOO_MUCH, w_max = 0;
        int h_min = TOO_MUCH, h_max = 0;
        int n; scanf("%d", &n);
        for(int i = 0; i < n; i++)
        {
            scanf("%d%d%d%d",w1+i,w2+i,h1+i,h2+i);
            if(w1[i] < w_min) w_min = w1[i];
            if(w2[i] > w_max) w_max = w2[i];
            if(h1[i] < h_min) h_min = h1[i];
            if(h2[i] > h_max) h_max = h2[i];
        }
        bool res = 0;
        for(int i = 0; i < n; i++)
            if(w1[i] == w_min &&
               w2[i] == w_max &&
               h1[i] == h_min &&
               h2[i] == h_max)
            {
                res = 1; break;
            }
        printf("%s",res?"TAK\n":"NIE\n");
    }
    return 0;
}