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
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, char *argv[]){
    int t; //ilosc testow
    int n; // ilosc zakladow
    int k;
    int w1,w2,h1,h2;
    int wmin, wmax, hmin, hmax;
    int tak = 1;
    int tmp;

    scanf( "%d", &t );
    while (t--) {
	scanf( "%d", &n );
	scanf( "%d %d %d %d", &wmin, &wmax, &hmin, &hmax );
	tak = 1;
	for (k=1; k<n; k++){
	    scanf( "%d %d %d %d", &w1, &w2, &h1, &h2 );
	    if (w1<wmin){ 
		tak = 0;
		wmin = w1;
		tmp = 1;
	    }else if (w1==wmin){
		tmp = 1;
	    }else{
		tmp = 0;
	    }
	    
	    if (w2>wmax){
		tak = 0;
		wmax = w2;
		tmp += 1;
	    }else if (w2==wmax){
		tmp += 1;
	    }
	    
	    if (h1<hmin){
		tak = 0;
		hmin = h1;
		tmp += 1;
	    }else if (h1==hmin){
		tmp += 1;
	    }
	    
	    if (h2>hmax) {
		tak = 0;
		hmax = h2;
		tmp += 1;
	    }else if (h2==hmax){
		tmp += 1;
	    }
	    
	    if (tmp==4){
		tak = 1;
	    }
	}
	if (tak)
	    printf("TAK\n");
	else
	    printf("NIE\n");
    }
    return 0;
}