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

const int mini = 1000000000;
set <pair < pair <int, int>, pair <int, int> > > sSet;
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		int iIlosc;
		scanf("%d", &iIlosc);
		int W1, W2, H1, H2,	
			MW1 = mini, MW2 = 0, MH1 = mini, MH2 = 0;
		for (int j = 0; j < iIlosc; j++)
		{
			scanf("%d %d %d %d", &W1, &W2, &H1, &H2);
			MW1 = min(MW1, W1);
			MW2 = max(MW2, W2);
			MH1 = min(MH1, H1);
			MH2 = max(MH2, H2);
			sSet.insert(make_pair(make_pair(W1, W2), make_pair(H1, H2)));
		}
		pair < pair <int, int>, pair <int, int> > pSearch = make_pair(make_pair(MW1, MW2), make_pair(MH1, MH2));
//		cout << pSearch.first.first << " " << pSearch.first.second << " " << pSearch.second.first << " " << pSearch.second.second << endl;
		if (sSet.count(pSearch) > 0)
		{
			printf("TAK\n");
		}
		else
		{
			printf("NIE\n");
		}
	}
	return 0;

}