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

using namespace std;

pair<long long,long long> w[100005];
pair<long long,long long>  h[100005];

int main()
{
    int testCases = 0;
    scanf( "%d", &testCases );
    for( int test = 0; test < testCases; ++test )
    {
        int n;
        scanf( "%d", &n );
        long long maxW = 0;
        long long minW = 10000000000ll;
        long long maxH = 0;
        long long minH = 10000000000ll;

        for( int i = 0; i < n; i++ )
        {
            scanf( "%d%d%d%d", &w[i].first, &w[i].second, &h[i].first, &h[i].second );
            minW = min( minW, w[i].first );
            maxW = max( maxW, w[i].second );
            minH = min( minH, h[i].first );
            maxH = max( maxH, h[i].second );
        }

        bool found = false;

        for( int i = 0; i < n; ++i )
        {
            if(( make_pair( minW, maxW ) == w[i] ) && ( make_pair( minH, maxH ) == h[i] ))
            {
                found = true;
                break;
            }
        }

        if( found )
            printf( "TAK\n" );
        else
            printf( "NIE\n" );

    }

    return 0;
}