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

using namespace std;

#define MAXINT 2000000000
#define N 100000

int minx[N];
int miny[N];
int maxx[N];
int maxy[N];

int main()
{
    int t,n;

    cin >> t;

    for(int i = 0; i < t; i++)
    {
        cin >> n;
        unsigned int g_minx = MAXINT, g_maxx = 0, g_miny = MAXINT,g_maxy = 0;

        for(int j = 0;j< n; j++)
        {
             //unsigned int minx, maxx, miny,maxy;

            cin >> minx[j] >>maxx[j] >>miny[j] >> maxy[j];
            if(minx[j] <=  g_minx && maxx[j] >= g_maxx && miny[j] <= g_miny && maxy[j] >= g_maxy )
            {
                g_minx = minx[j];
                g_maxx = maxx[j];
                g_miny = miny[j];
                g_maxy = maxy[j];
            }
        }
        bool notIncluding = false;
        for(int j = 0;j< n; j++)
        {
            if(!(minx[j] >=  g_minx && maxx[j] <= g_maxx && miny[j] >= g_miny && maxy[j] <= g_maxy ))
            {
                notIncluding = true;
                break;
            }
        }
        if(notIncluding)
        {
            cout<<"NIE"<<endl;
        }
        else
        {
            cout<<"TAK"<<endl;
        }
    }

    return 0;
}