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

using namespace std;

int main()
{
    long int w1[100000], w2[100000], h1[100000], h2[100000];
    int t;
    cin >> t;
    for (int ti=0;ti<t;ti++){
        int n;
        cin >> n;
        for (int ni=0;ni<n;ni++)
            cin>>w1[ni]>>w2[ni]>>h1[ni]>>h2[ni];

        long int minW1=w1[0], maxW2=w2[0], minH1=h1[0], maxH2=h2[0];
        for (int ni=1;ni<n;ni++){
            minW1=min(minW1, w1[ni]);
            maxW2=max(maxW2, w2[ni]);
            minH1=min(minH1, h1[ni]);
            maxH2=max(maxH2, h2[ni]);
        }
        bool retValue=false;
        for (int ni=0;ni<n;ni++){
            if (minW1==w1[ni] && maxW2==w2[ni] && minH1==h1[ni] && maxH2==h2[ni]){
                retValue=true;
                break;
            }
        }
        cout<<(retValue?"TAK":"NIE")<<endl;
    }
    return 0;
}