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

using namespace std;

int main()
{
    int t,n,w1,w2,h1,h2,s1,s2,y1,y2,z=0,k=4;
    cin>>t;
    for(int x=0;x<t;x++)
    {
        cin>>n;
        cin>>w1>>w2>>h1>>h2;
        s1=w1;
        s2=w2;
        y1=h1;
        y2=h2;
        for(int i=0;i<n-1;i++)
        {
            cin>>w1>>w2>>h1>>h2;
            if(w1<s1)
            {
                s1=w1;
                z++;
            }
            if(w2>s2)
            {
                s2=w2;
                z++;
            }
            if(h1<y1)
            {
                y1=h1;
                z++;
            }
            if(h2>y2)
            {
                y2=h2;
                z++;
            }
            if(z==0)
            k=4;
            else
            k=z;

            z=0;
        }
        if(k==4)
        cout<<"TAK"<<endl;
        else
        cout<<"NIE"<<endl;
    }
    return 0;
}