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
#include <iostream>
using namespace std;
typedef struct _firma{
	unsigned minw, maxw, minh, maxh;
} dane;
int main () {
	ios_base::sync_with_stdio (false);
	unsigned t, n, major, index, minw, maxw, minh, maxh;
	dane firma [100000];
	cin >> t;
	for(int p = 0;p<t;++p){
		cin >> n >> firma[0].minw >> firma[0].maxw  >> firma[0].minh >> firma[0].maxh;
		major = 0;
		minw = firma[0].minw;
		maxw = firma[0].maxw;
		minh = firma[0].minh;
		maxh = firma[0].maxh;

		for(int i = 1;i<n;++i){
			cin >> firma[i].minw >> firma[i].maxw  >> firma[i].minh >> firma[i].maxh;
			if(firma[i].minw<minw)
				minw = firma[i].minw;
			if(firma[i].maxw>maxw)
				maxw = firma[i].maxw;
			if(firma[i].minh<minh)
				minh = firma[i].minh;
			if(firma[i].maxh>maxh)
				maxh = firma[i].maxh;
		}
		for(int i = 0;i<n;++i){
			if(firma[i].minw==minw&&firma[i].maxw==maxw&&firma[i].minh==minh&&firma[i].maxh==maxh){
				major = 1;
				break;
			}
		}
		if(major)
			cout << "TAK\n";
		else
			cout << "NIE\n";
	}
	return 0;
}