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
#include<cstdio>
#include<vector>
#include<string>
using namespace std;
int main(){
    vector <string> W;
    int t,n;
    long w1,w2,h1,h2;
    long wmin,wmax,hmin,hmax;
    long wmin1,wmax1,hmin1,hmax1;
    scanf("%d",&t);
    for(int i=0;i<t;i++){
        wmin=9000000001;
        wmax=0;
        hmin=9000000001;
        hmax=0;
        wmin1=9000000001;
        wmax1=0;
        hmin1=9000000001;
        hmax1=0;
        scanf("%d",&n);
        for(int j=0;j<n;j++){
            scanf("%ld%ld%ld%ld",&w1,&w2,&h1,&h2);
            if(w1<wmin && w2>wmax && h1<hmin && h2>hmax){
                wmin=w1;
                wmax=w2;
                hmin=h1;
                hmax=h2;
            }
            if(w1<wmin1)wmin1=w1;
            if(w2>wmax1)wmax1=w2;
            if(h1<hmin1)hmin1=h1;
            if(h2>hmax1)hmax1=h2;
        }
        if(wmin==wmin1 && wmax==wmax1 && hmin==hmin1 && hmax==hmax1)W.push_back("TAK");
        else W.push_back("NIE");
    }
    for(int i=0;i<t;i++) printf("%s\n",W[i].c_str());
    return 0;
}