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
#include <cstdio>
#include <algorithm>
#define INF 1000000000
using namespace std;
int arr[100000][4];
int n;
int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        scanf("%d", &n);
        int w1 = INF;
        int w2 = 0;
        int h1 = INF;
        int h2 = 0;
        for (int i = 0; i < n; i++) {
            for (int k = 0; k < 4; k++) {
                scanf("%d", &arr[i][k]);
            }
            w1 = min(w1, arr[i][0]);
            w2 = max(w2, arr[i][1]);
            h1 = min(h1, arr[i][2]);
            h2 = max(h2, arr[i][3]);
        }
        bool succ = false;
        for (int i = 0; i < n; i++) {
            if (w1 == arr[i][0] && w2 == arr[i][1] && h1 == arr[i][2] && h2 == arr[i][3]) {
                succ = true;
                break;
            }
        }
        if (succ) {
            printf("TAK\n");
        } else {
            printf("NIE\n");
        }
    }
    return 0;
}