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

using namespace std;

struct dim
{
    int a,b,c,d;
};

int main()
{
    int T;
    scanf("%i", &T);

    while (T --> 0)
    {
        int N;
        scanf("%i", &N);

        dim* tab = new dim[N];
        for (int i=0; i<N; i++)
        {
            scanf("%i%i%i%i",
                    &tab[i].a,
                    &tab[i].b,
                    &tab[i].c,
                    &tab[i].d);
        }

        int ma = tab[0].a;
        int mb = tab[0].b;
        int mc = tab[0].c;
        int md = tab[0].d;
        for (int i=0; i<N; i++)
        {
            if (tab[i].a < ma)
                ma = tab[i].a;

            if (tab[i].b > mb)
                mb = tab[i].b;

            if (tab[i].c < mc)
                mc = tab[i].c;
            
            if (tab[i].d > md)
                md = tab[i].d;
        }

        bool found = false;
        for (int i=0; found == false && i<N; i++)
        {
            if (tab[i].a == ma && tab[i].b == mb && tab[i].c == mc && tab[i].d == md)
            {
                printf("TAK\n");
                found = true;
            }
        }

        if (found == false)
            printf("NIE\n");

        delete [] tab;
    }
}