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
//Jakub Sygnowski
#include <cstdio>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
#define F first
#define S second
#define MAXN 100007
#define MAX 1000000007
pii wys[MAXN], szer[MAXN];
int a, b, x, y;
int n, t;
int main(){
    scanf("%d",&t);
    while(t--){
        a = MAX; x = MAX;
        b = 0; y = 0;
        scanf("%d",&n);
        for(int i = 0; i < n; i++){
            scanf("%d%d%d%d", &wys[i].F, &wys[i].S, &szer[i].F, &szer[i].S);
            a = min(a, wys[i].F);
            b = max(b, wys[i].S);
            x = min(x, szer[i].F);
            y = max(y, szer[i].S);
        }
        bool solved = false;
        for(int i = 0; i < n; i++){
            if (wys[i].F == a && wys[i].S == b && szer[i].F == x && szer[i].S == y){
                solved = true;
                printf("TAK\n");
                break;
            }
        }
        if (!solved){
            printf("NIE\n");
        }
    }
}