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
#include <iostream>

using namespace std;


int main()
{
    int minw1=1000000000,maxw2=0,minh1=1000000000,maxh2=0;
    int pw1,pw2,ph1,ph2;
    ios_base::sync_with_stdio(0);
    int t,n,w1[100007],w2[100007],h1[100007],h2[100007];
    cin>>t;
   for(int j=0;j<t;j++)
    {
        pw1=0;pw2=0;ph1=0;ph2=0;
        minw1=1000000000;maxw2=0;minh1=1000000000;maxh2=0;
        cin>>n;
            for (int i=0;i<n;i++)
                {
                cin>>w1[i]>>w2[i]>>h1[i]>>h2[i];
                  if(w1[i]<minw1)
                  {
                      minw1=w1[i];
                      pw1=i;
                  }
                   if(w2[i]>maxw2)
                  {
                      maxw2=w2[i];
                      pw2=i;
                  }
                   if(h1[i]<minh1)
                  {
                      minh1=h1[i];
                      ph1=i;
                  }
                   if(h2[i]>maxh2)
                  {
                      maxh2=h2[i];
                      ph2=i;
                  }
                }
if(pw1==pw2&&pw2==ph1&&ph1==ph2&&pw1==ph2)cout<<"TAK"<<endl;
else cout<<"NIE"<<endl;

    }


    return 0;
}