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 <iostream>
#include <cstdio>
using namespace std;

int w1[100001], w2[100001], h1[100001], h2[100001];
int t, n, wmin, wmax, hmin, hmax;
bool tak;

int main()
{
    scanf("%d", &t);
    for(int i=1;i<=t;i++)
    {
        wmin=1000000000, hmin=1000000000;
        wmax=0, hmax=0, tak=0;
        scanf("%d", &n);
        for(int j=1;j<=n;j++)
        {
            scanf("%d%d%d%d", &w1[j], &w2[j], &h1[j], &h2[j]);
            wmin=min(wmin, w1[j]);
            wmax=max(wmax, w2[j]);
            hmin=min(hmin, h1[j]);
            hmax=max(hmax, h2[j]);
        }
        for(int j=1;j<=n;j++)
        {
            if(w1[j]==wmin&&w2[j]==wmax&&h1[j]==hmin&&h2[j]==hmax)
            {
                printf("TAK\n");
                tak=1;
                break;
            }
        }
        if(tak==0)
            printf("NIE\n");
    }
    return 0;
}