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

const int MAX = 1000000001;
const int N = 100000;
int a[N][4];

bool zestaw()
{
	int minw = MAX;
	int minh = MAX;
	int maxw = 0;
	int maxh = 0;
	int n;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
		minw = min(minw, a[i][0]);
		maxw = max(maxw, a[i][1]);
		minh = min(minh, a[i][2]);
		maxh = max(maxh, a[i][3]);
	}
	for (int i = 0; i < n; ++i)
		if (a[i][0] == minw && a[i][1] == maxw && a[i][2] == minh
				&& a[i][3] == maxh) return true;
	return false;
}

int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; ++i) {
		if (zestaw()) cout <<  "TAK\n";
		else cout << "NIE\n";
	}
	return 0;
}