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

using namespace std;

struct lustro
{
    int h1;
    int h2;
    int w1;
    int w2;
};

int main()
{
    int t;
    scanf("%d", &t);
    for( int i = 0; i < t; i ++ )
    {
        int n;
        scanf("%d", &n);
        lustro tab[n];
        int max_h, min_h, max_w, min_w;
        scanf("%d %d %d %d", &min_h, &max_h, &min_w, &max_w );
        tab[0].h1 = min_h;
        tab[0].h2 = max_h;
        tab[0].w1 = min_w;
        tab[0].w2 = max_w;
        for( int j = 1; j < n; j ++ )
        {
            scanf("%d %d %d %d", &tab[j].h1, &tab[j].h2, &tab[j].w1, &tab[j].w2 );
            min_h = min( min_h, tab[j].h1 );
            max_h = max( max_h, tab[j].h2 );
            min_w = min( min_w, tab[j].w1 );
            max_w = max( max_w, tab[j].w2 );
        }
        bool flag = false;
        for( int j = 0; j < n; j ++ )
        {
            if( tab[j].h1 == min_h && tab[j].h2 == max_h )
            {
                if( tab[j].w1 == min_w && tab[j].w2 == max_w )
                {
                    flag = true;
                    break;
                }
            }
        }
        //cout << min_h << " " << max_h << " " << min_w << " " << max_w << endl;
        if( flag == true ) printf("TAK\n");
        else printf("NIE\n");
    }
    return 0;
}