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

int t,n,w1,w2,h1,h2;

int main(int argc, char** argv) {
	//scanf("%d",&t);
	ios_base::sync_with_stdio(0);
	cin >> t;
	while (t--) {
		//scanf("%d",&n);
		cin >> n;
		int wmi=1000000001; int wma=0;
		int hmi=1000000001; int hma=0;
		int ww1,ww2,hh1,hh2;
		bool ok=false;
		for (int i=0;i<n;i++) {
			//scanf("%d%d%d%d",&w1,&w2,&h1,&h2);
			cin >> w1 >> w2 >> h1 >> h2;
			int z=0;
			if (w1<=wmi) {wmi=w1; z++;} 
			if (w2>=wma) {wma=w2; z++;}
			if (h1<=hmi) {hmi=h1; z++;}
			if (h2>=hma) {hma=h2; z++;}
			if (z==4) {
				ok = true;
				ww1=wmi; ww2=wma; hh1=hmi; hh2=hma;
			} else { 
				if (ok)
					ok = w1>=ww1 && w2<=ww2 && h1>=hh1 && h2<=hh2;
			}
		}
		//puts(ok?"TAK":"NIE");
		cout << (ok?"TAK\n":"NIE\n");
	}
	return 0;
}