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

using namespace std;

const int MAX_SIZE = 1000000000;
int tab[100000][4];

int main() {
    int t, n, w1, w2, h1, h2;
    scanf("%d", &t);
    while (t--) {
        int w1Min = MAX_SIZE;
        int w2Max = 1;
        int h1Min = MAX_SIZE;
        int h2Max = 1;
        bool res = false;
        scanf("%d", &n);
        for (int i=0; i<n; i++) {
            scanf("%d%d%d%d", &w1, &w2, &h1, &h2);
            w1Min = min(w1, w1Min);
            w2Max = max(w2, w2Max);
            h1Min = min(h1, h1Min);
            h2Max = max(h2, h2Max);
            tab[i][0] = w1;
            tab[i][1] = w2;
            tab[i][2] = h1;
            tab[i][3] = h2;
        }
        for (int i=0; i<n; i++) {
            if ((w1Min == tab[i][0]) && (w2Max == tab[i][1]) && (h1Min == tab[i][2]) && (h2Max == tab[i][3])) {
                res = true;
                break;
            }
        }
        if (res) printf("TAK\n");
        else printf("NIE\n");
    }
    return 0;
}