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
#include<cstdio>
#include<iostream>
using namespace std;
struct firma
{
    int mins,maxs,minw,maxw;
};
firma tab[100001];
int main()

{ios_base::sync_with_stdio(0);

    firma major;int ile,zes;
    cin>>zes;

    for(int a=0;a<zes;a++)
    {   major.mins=2000000000;
        major.minw=2000000000;
        major.maxw=0;
        major.maxs=0;

        cin>>ile;
        for(int i=0;i<ile;i++)
        {
            cin>>tab[i].mins>>tab[i].maxs>>tab[i].minw>>tab[i].maxw;

            if(tab[i].mins<major.mins)major.mins=tab[i].mins;
            if(tab[i].maxs>major.maxs)major.maxs=tab[i].maxs;
            if(tab[i].minw<major.minw)major.minw=tab[i].minw;
            if(tab[i].maxw>major.maxw)major.maxw=tab[i].maxw;
        }

       // cout<<"Asdfasdf"<<major.mins<<major.maxs<<major.minw<<major.maxw<<endl;
       bool czy=false;
       for(int i=0;i<ile;i++)
        if(tab[i].mins==major.mins &&
            tab[i].maxs==major.maxs &&
            tab[i].minw==major.minw &&
            tab[i].maxw==major.maxw
          ){czy=true;break;}

          if(czy)cout<<"TAK"<<endl;else cout<<"NIE"<<endl;

    }
return 0;
}