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 <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int t;
    cin>>t;
    int w1[100000],w2[100000],h1[100000],h2[100000];
    while(t--)
    {
        int n;
        cin>>n;
        int wmin=1000000001,wmax=0,hmin=1000000001, hmax=0;

        for(int i=0;i<n;++i)
        {
            scanf("%d %d %d %d,",&w1[i],&w2[i],&h1[i],&h2[i]);
            if(wmin>=w1[i] && wmax<=w2[i] && hmin>=h1[i] && hmax<=h2[i])
            {
                wmin=w1[i];
                wmax=w2[i];
                hmin=h1[i];
                hmax=h2[i];
            }
        }
        bool majoryzacja=true;
        for(int i=0;i<n;++i)
        {
           // scanf("%d %d %d %d,",&w1[i],&w2[i],&h1[i],&h2[i]);
            if(wmin>w1[i] || wmax<w2[i] || hmin>h1[i] || hmax<h2[i])
            {
                majoryzacja=false;
            }
        }
        if(majoryzacja)
        {
            cout<<"TAK\n";
        }
        else
        {
            cout<<"NIE\n";
        }
    }

}