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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct firma
{
	long long int w_min;
	long long int w_max;
	long long int h_min;
	long long int h_max;
	long long int numer;
};

firma tablica[1000001];

long long int W_MIN, W_MAX, H_MIN, H_MAX;

int main()
{
	ios_base::sync_with_stdio(0);
	
	long long int t;
	cin >> t;
	
	for(long long int ii = 1; ii <= t; ii++)
	{
		long long int n;
		cin >> n;
		
		cin >> tablica[1].w_min;
		cin >> tablica[1].w_max;
		cin >> tablica[1].h_min;
		cin >> tablica[1].h_max;
		
		W_MIN = tablica[1].w_min;
		W_MAX = tablica[1].w_max;
		H_MIN = tablica[1].h_min;
		H_MAX = tablica[1].h_max;
		
		for(int i = 2; i <= n; i++)
		{
			cin >> tablica[i].w_min;
			cin >> tablica[i].w_max;
			cin >> tablica[i].h_min;
			cin >> tablica[i].h_max;
			
			if(tablica[i].w_min <= W_MIN)
				W_MIN = tablica[i].w_min;
				
			if(tablica[i].w_max >= W_MAX)
				W_MAX = tablica[i].w_max;
				
			if(tablica[i].h_min <= H_MIN)
				H_MIN = tablica[i].h_min;
				
			if(tablica[i].h_max >= H_MAX)
				H_MAX = tablica[i].h_max;
		}
		
		bool mm = true;
		
		for(long long int i = 1; i <= n ; i++)
		{
			if(tablica[i].h_min == H_MIN && tablica[i].h_max == H_MAX &&
			   tablica[i].w_min == W_MIN && tablica[i].w_max == W_MAX)
				{
					mm = false;
					break;
				}
		}
		
		if(mm == true)
			cout << "NIE" << endl;
		else
			cout << "TAK" << endl;
	}

	return 0;
}