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
#include<vector>
#include<cstdio>
#define inf 1000000100
using namespace std;

struct kwartet{
    int w, W, h, H;
    kwartet(){}
};

vector< kwartet> data;

void solve() {
    int n, h=inf, H=0, w=inf, W=0;
    scanf("%d", &n);
    data.resize(0);
    data.resize(n);
    for(int i=0; i<n; ++i) {
        int a, b, c, d;
        scanf("%d%d%d%d",&a, &b, &c, &d);
        h = min(h, a);
        H = max(H, b);
        w = min(w, c);
        W = max(W, d);
        data[i].h=a;
        data[i].H=b;
        data[i].w=c;
        data[i].W=d;
    }
    for(int i=0; i<n; ++i)
        if(data[i].h == h and data[i].H == H and data[i].w == w and data[i].W == W)
        {
            printf("TAK\n");
            return ;
        }
    printf("NIE\n");
    return ;
}

int main() {
    int testy;
    scanf("%d", &testy);
    while(testy--) {
        solve();
    }
    return 0;
}