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
#include <iostream>
using namespace std;
int i, t, n, w1, w2, h1, h2, min_w, max_w, min_h, max_h;
int A[100001][4];
int main() {
	ios_base::sync_with_stdio(0);	
	cin >> t;
	while(t--)
	{
		cin >> n;
		cin >> A[0][0] >> A[0][1] >> A[0][2] >> A[0][3];
		min_w = A[0][0]; max_w = A[0][1]; min_h = A[0][2]; max_h = A[0][3];
		for( i = 1; i < n; ++i) {
			cin >> A[i][0] >> A[i][1] >> A[i][2] >> A[i][3];
			min_w = min(min_w , A[i][0]);
			max_w = max(max_w , A[i][1]);
			min_h = min(min_h , A[i][2]);
			max_h = max(max_h , A[i][3]);			
		}
		for( i = 0; i < n; ++i) {
			if (A[i][0] == min_w && A[i][1] == max_w && A[i][2] == min_h && A[i][3] == max_h) {
				cout << "TAK\n";
				break;
			}
		}
		if (i == n) cout << "NIE\n";		
	}

return 0;
 
}