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;


main()
{
	ios_base::sync_with_stdio(0);  // usunac kom
	int t,n;
	int wmin[100001], hmin[100001], wmaks[100001], hmaks[100001];
	int w1,w2,h1,h2;
	cin>>t;
	bool tym;
	while(t--)
	{
		tym=false;
		w2=0, h2=0, w1=1000000001, h1=1000000001;
		cin>>n;
		for(int i=0;i<n;i++)
		{
			cin>>wmin[i]>>wmaks[i]>>hmin[i]>>hmaks[i];
			w1=min(w1, wmin[i]);
			w2=max(w2, wmaks[i]);
			h1=min(h1, hmin[i]);
			h2=max(h2, hmaks[i]);	
		}
		for(int i=0;i<n;i++)
		{
			if(wmin[i]==w1 && wmaks[i]==w2 && hmin[i]==h1 && hmaks[i]==h2)
			{
				tym=true;
				cout<<"TAK"<<endl;
				break;
			}
		}
		if(tym==false) cout<<"NIE"<<endl;
		
	}
	
	
	
}