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

#define INF 1000000001

using namespace std;

int min(int a,int b)
{
    if (a<b)return a;return b;
}

int max(int a,int b)
{
    if (a>b)return a;return b;
}

int main()
{
    int T,N;

    int maX,maY;
    int miX,miY;

    scanf("%d",&T);

    int t,a;

    for (t=0;t<T;t++)
    {
        maX=maY=-1;
        miX=miY=INF;

        scanf("%d",&N);

        int *W1=new int[N];
        int *W2=new int[N];

        int *H1=new int[N];
        int *H2=new int[N];

        for (a=0;a<N;a++)
        {
            scanf("%d%d%d%d",&W1[a],&W2[a],&H1[a],&H2[a]);
            maX=max(maX,W2[a]);
            maY=max(maY,H2[a]);

            miX=min(miX,W1[a]);
            miY=min(miY,H1[a]);
        }
        for (a=0;a<N;a++)
        {
            if (maX==W2[a] && maY==H2[a] && miX==W1[a] && miY==H1[a]) break;
        }

        if (a==N) printf("NIE\n");
        else printf("TAK\n");
    }

    return 0;
}