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
#include <stdio.h>
int main() {
    int t, n;
    scanf("%d\n", &t);
    for(int i=0;i<t;i++) {
        int rv = 0;
        int minw = 100000;
        int minh = 100000;
        int maxw = 0;
        int maxh = 0;
        int h1, h2, w1, w2;
        scanf("%d\n", &n);
        for(int j=0;j<n;j++) {
            scanf("%d %d %d %d\n", &w1, &w2, &h1, &h2);
            if (w1 <= minw && w2 >= maxw && h1 <= minh && h2 >= maxh) {
                rv = 1;
                minw = w1;
                maxw = w2;
                minh = h1;
                maxh = h2;
            } else {
                if (w1 < minw) { minw = w1; rv = 0; };
                if (w2 > maxw) { maxw = w2; rv = 0; };
                if (h1 < minh) { minh = h1; rv = 0; };
                if (h2 > maxh) { maxh = h2; rv = 0; };
            }
        }
        if (rv) {
            printf("TAK\n");
        } else {
            printf("NIE\n");
        }
    }
    return 0;
}