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
#include<cstdio>
int main()
{
    int n;
    scanf("%d",&n);
    for (int i=0; i<n; i++)
    {
        bool wyn=true;
        int wmin=1000000001,hmin=1000000001,wmax=0,hmax=0;
        int k;
        scanf("%d",&k);    
        for (int j=0; j<k; j++)
        {
            int w1,w2,h1,h2;
            scanf("%d%d%d%d",&w1,&w2,&h1,&h2);    
            if (( (w1<wmin) || (w2>wmax) || (h1<hmin) || (h2>hmax))==true)
            { 
              if (( (w1<=wmin) && (w2>=wmax) && (h1<=hmin) && (h2>=hmax) )==false) wyn=false;
              if (wmin>w1) wmin=w1;
              if (wmax<w2) wmax=w2;
              if (hmin>h1) hmin=h1;
              if (hmax<h2) hmax=h2;  
            }
        }
        if (wyn==true) printf("TAK\n"); else printf("NIE\n");    
    } 
    return 0;   
}