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
#include <stdio.h>
#include <algorithm>
#include <climits>

using namespace std;

struct lustro {
    int x1, x2;
    int y1, y2;
};

typedef struct lustro lustro;

int t, n;

lustro ls[100000];

void go() {
    int minx = INT_MAX, maxx = 0, 
        miny = INT_MAX, maxy = 0;
    scanf("%d", &n);
    for(int i=0; i < n; i++) {
        lustro &l = ls[i];
        scanf("%d %d %d %d", &l.x1, &l.x2, &l.y1, &l.y2);        
        minx = min(minx, l.x1);
        maxx = max(maxx, l.x2);
        miny = min(miny, l.y1);
        maxy = max(maxy, l.y2);
    }
    // printf("%d %d %d %d\n", minx, maxx, miny, maxy);
    for(int i=0; i < n; i++) {
        lustro &l = ls[i];
        if (l.x1 <= minx && l.x2 >= maxx &&
            l.y1 <= miny && l.y2 >= maxy) {
                printf("TAK\n");
                return;
        }
    }
    printf("NIE\n");
}

int main() {

    scanf("%d", &t);

    while(t--) {
        go();
    }

    return 0;
}