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
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <vector>
using namespace std;

struct dim
{
	int x1, x2, y1, y2;
	dim(int a, int b, int c, int d)
	{
		x1 = a; x2 = b; y1 = c; y2 = d;
	}
	bool operator==( const dim& r)
	{
		if (x1 == r.x1 && x2 == r.x2 && y1 == r.y1 && y2 == r.y2)
			return true;
		return false;
	}
};

int main(int, char**)
{
	vector<dim> data;
	int t, n, minx, maxx, miny, maxy, X1, X2, Y1, Y2;
		
	cin >> t;
	while (t--)
	{
		X1 = 1000000001, X2 = 0, Y1 = 1000000001, Y2 = 0;
		cin >> n;

		for (int a = 0; a < n;a++)
		{
			cin >> minx >> maxx >> miny >> maxy;
			data.push_back(dim(minx, maxx, miny, maxy));
			X1 = (minx < X1) ? minx : X1;
			X2 = (maxx > X2) ? maxx : X2;
			Y1 = (miny < Y1) ? miny : Y1;
			Y2 = (maxy > Y2) ? maxy : Y2;
		}
		dim mm = dim(X1, X2, Y1, Y2);
		int odp = 0;
		for (dim a : data)
		{
			if (a == mm)
				odp++;
		}
		if (odp > 0)
			cout << "TAK" << endl;
		else
			cout << "NIE" << endl;
		data.clear();
	}
	return 0;
}