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
47
48
49
50
51
52
53
#include <stdio.h>

int sprawdz( void ) {
    int N;
    int w1, w2, h1, h2;
    int mw1=1000000001, mw2=0, mh1=1000000001, mh2=0;
    int semafor = 0;
    int i;

    scanf("%d", &N);

    for( i=0; i<N; i++ ) {
        scanf("%d %d %d %d", &w1, &w2, &h1, &h2);

        if( (w1 <= mw1) && (w2>=mw2) && (h1 <= mh1) && (h2 >= mh2) ) {
            mw1 = w1; mw2 = w2; mh1 = h1; mh2 = h2;
            semafor = 1;
            continue;
        }

        if( (w1 >= mw1) && (w2<=mw2) && (h1 >= mh1) && (h2 <= mh2) ) {
            continue;
        }


        semafor = 0;

        if( w1 <= mw1) mw1 = w1;
        if( w2 >= mw2) mw2 = w2;
        if( h1 <= mh1) mw1 = w1;
        if( h2 >= mh2) mw2 = w2;
    }


    return semafor;
}

int main( void ) {

    int N;
    int i;

    scanf("%d", &N);

    for( i=0; i< N; i++ ) {
        if( sprawdz() == 1 )
            printf("TAK\n");
        else
            printf("NIE\n");
    }

    return 0;
}