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
#include<iostream>
using namespace std;
int t,n;
long long int a, b, c, d, ma, mb, mc, md, A, B, C, D;
bool wynik;

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>t;
    while(t--)
    {
        wynik=false;
        cin>>n;
        cin>>ma>>mb>>mc>>md;
        A=ma;
        B=mb;
        C=mc;
        D=md;
        n--;
        while(n--)
        {
            cin>>a>>b>>c>>d;
            if(((a<=ma)&&(b>=mb))&&((c<=mc)&&(d>=md)))
            {
              A=a;
              B=b;
              C=c;
              D=d;
            }
            if(a<ma) ma=a;
            if(b>mb) mb=b;
            if(c<mc) mc=c;
            if(d>md) md=d;
        }
        if(A==ma&&B==mb&&C==mc&&D==md)
            wynik=true;
        cout<<((wynik)?"TAK":"NIE")<<endl;
    }
    return 0;
}