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

int a[100001];
int b[100001];
int c[100001];
int d[100001];

int main()
{
	ios_base::sync_with_stdio(0);
	int prz;
	cin >> prz;
	for(int lic = 0; lic < prz; ++lic)
	{
		int n;
		cin >> n;
		int mina = 1 << 30;
		int minc = 1 << 30;
		int maxb = 0;
		int maxd = 0;
		for(int i = 0; i < n; ++i) 
		{
			cin >> a[i] >> b[i] >> c[i] >> d[i];
			mina = min(mina, a[i]);
			minc = min(minc, c[i]);
			maxb = max(maxb, b[i]);
			maxd = max(maxd, d[i]);
		}

		int w = 0;
		for(int i = 0; i < n; ++i) if(a[i] == mina && b[i] == maxb && c[i] == minc && d[i] == maxd) w = 1;
		if(w) cout << "TAK\n";
		else cout << "NIE\n";
	}
	return 0;
}