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


int t;
int zak;
bool odp = 1;

int main()
{
    scanf("%d", &t);

    for(int i = 0; i<t; ++i)
    {
        int minw = 1000000001, maxw = 0, minh = 1000000001, maxh = 0;

        scanf("%d", &zak);

        for(int j = 0;j<zak; ++j)
        {
            int spr = 0, sprr = 0;
            int c;
            scanf("%d", &c);
            if(c < minw){minw = c; ++spr;}
                else if(c == minw)++sprr;

            scanf("%d", &c);
            if(c > maxw){maxw = c; ++spr;}
            else if(c == maxw)++sprr;

            scanf("%d", &c);
            if(c < minh){minh = c; ++spr;}
            else if(c == minh)++sprr;

            scanf("%d", &c);
            if(c > maxh){maxh = c; ++spr;}
            else if(c == maxh)++sprr;

            if(spr + sprr == 4) odp = 1;
                else if(spr != 0) odp = 0;
        }

        if(odp==1)printf("TAK\n");
            else printf("NIE\n");
            odp = 1;
    }

    return 0;
}