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
65
66
67
#include <iostream>

using namespace std;
unsigned int t,n,w1,w2,h1,h2,Hmin,Hmax,Wmin,Wmax;
bool ans,ex;


int main()
{
    cin>>t;
    while(t-->0)
    {
        cin>>n;
        {
            Hmax=Wmax=0;
            Hmin=Wmin=1000000001;
            ans = true;

            while(n-->0)
            {
                cin>>w1>>w2>>h1>>h2;
                ex=false;
                if(w1<Wmin){
                    Wmin=w1;
                    ex=true;
                }

                if(w2>Wmax){
                    Wmax=w2;
                    ex=true;
                }

                if(h1<Hmin){
                    Hmin=h1;
                    ex=true;
                }

                if(h2>Hmax){
                    Hmax=h2;
                    ex = true;
                }
                if(ex)
                {
                    if(((w1==Wmin)&&(w2==Wmax))&&((h1==Hmin)&&(h2==Hmax)))
                    {
                        ans = true;
                    }else{
                        ans = false;
                    }
                }

            }

            if(ans)
                cout<<"TAK";
            else
                cout<<"NIE";

            if(t>0)
                cout<<endl;
        }

    }


    return 0;
}