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

struct auction{
	int minWidth, maxWidth, minHeight, maxHeight;
	auction();
	auction(int);
};

auction::auction(){
	cin >> minWidth >> maxWidth >> minHeight >> maxHeight;
}

auction::auction(int shit){}


int main() {
	int t, amount;
	cin >> t;

	while (t--){
		cin >> amount;
		auction best, temp(1), * auctions = new auction [amount - 1];
		temp = best;
		for (int i = 0; i < amount - 1; i++){

			if ((auctions[i].minWidth < best.minWidth && auctions[i].maxWidth > best.maxWidth) ||
					(auctions[i].minHeight < best.minHeight && auctions[i].maxHeight > best.maxHeight))
				best = auctions[i];
			if (temp.minWidth > auctions[i].minWidth) 
				temp.minWidth = auctions[i].minWidth;
			if (temp.maxWidth < auctions[i].maxWidth)
				temp.maxWidth = auctions[i].maxWidth;
			if (temp.minHeight > auctions[i].minHeight) 
				temp.minHeight = auctions[i].minHeight;
			if (temp.maxHeight < auctions[i].maxHeight) 
				temp.maxHeight = auctions[i].maxHeight;
		}
		if (best.minWidth <= temp.minWidth && best.maxWidth >= temp.maxWidth
			&& best.minHeight <= temp.minHeight && best.maxHeight >= temp.maxHeight)
			cout << "TAK" << endl;
		else cout << "NIE" << endl;
		delete[] auctions;
	}
}