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

#define INF 1000000001

int main ()
{
    int t;
    int n;
    int tab [100000] [4];
    int minX = INF, maxX = 0, minY = INF, maxY = 0;
    scanf ("%d", &t);
    int i, j;
    for (j = 0; j < t; ++ j)
    {
        scanf ("%d", &n);
        minX = INF; maxX = 0; minY = INF; maxY = 0;
        for (i = 0; i < n; ++ i)
        {
            scanf ("%d %d %d %d", &tab [i] [0], &tab [i] [1],
                    &tab [i] [2], &tab [i] [3]);
            if (tab [i] [0] < minX) minX = tab [i] [0];
            if (tab [i] [1] > maxX) maxX = tab [i] [1];
            if (tab [i] [2] < minY) minY = tab [i] [2];
            if (tab [i] [3] > maxY) maxY = tab [i] [3];
        }
        bool flag = true;
        for (i = 0; i < n; ++ i)
        {
            if (tab [i] [0] <= minX && tab [i] [1] >= maxX &&
                    tab [i] [2] <= minY && tab [i] [3] >= maxY)
            {
                printf ("TAK\n");
                flag = false;
                break;
            }
        }
        if (flag)
            printf ("NIE\n");
    }
    return 0;
}