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
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <cstdio>
#include <vector>

using namespace std;

int n,t;

int main() {
	scanf("%d", &t);
	for(int i =0; i<t; i++){
        vector <vector <unsigned int> > tab;
        vector <vector <bool> > cir;
        tab.resize(4);
        cir.resize(4);
        scanf("%d", &n);
        for(int i =0; i <4; i++){
            tab[i].resize(n);
            cir[i].resize(n, false);
        }
        
        for (int i =0; i<n; i++){
            scanf("%d", &tab[0][i]);
            scanf("%d", &tab[1][i]);
            scanf("%d", &tab[2][i]);
            scanf("%d", &tab[3][i]);
        }
        
        unsigned int min=2000000000;
        for (int i =0; i<n ;i++){
            if(tab[0][i]<min) min = tab[0][i];
        }
        for (int i =0; i<n ;i++){
            if(tab[0][i]==min)	cir[0][i]=true;
        }
        unsigned int max=0;
        for (int i =0; i<n ;i++){
            if(tab[1][i]>max) max = tab[1][i];
        }
        for (int i =0; i<n ;i++){
            if(tab[1][i]==max)	cir[1][i]=true;
        }
        min=2000000000;
        for (int i =0; i<n ;i++){
            if(tab[2][i]<min) min = tab[2][i];
        }
        for (int i =0; i<n ;i++){
            if(tab[2][i]==min)	cir[2][i]=true;
        }
        max=0;
        for (int i =0; i<n ;i++){
            if(tab[3][i]>max) max = tab[3][i];
        }
        for (int i =0; i<n ;i++){
            if(tab[3][i]==max)	cir[3][i]=true;
        }
        bool ok =false;
        for (int i =0; i<n && !ok ;i++){
            if(cir[0][i] && cir[1][i] && cir[2][i] && cir[3][i]) ok=true;
        }
        if(ok)printf("TAK\n");
        else printf("NIE\n");
	}	
	return 0;
}