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

int main() {
	int t;
	long z;
	long w1_min, w2_max;
	long h1_min, h2_max;
	long w1, w2, h1, h2;

	cin >> t;					// ilosc testow

	for (int i = 0; i < t; ++i) {
		cin >> z;				// ilosc zakladow w danym tescie

		cin >> w1_min;	// zalozenie ze pierwsza firma majoryzuje oferty pozostalych
		cin >> w2_max;
		cin >> h1_min;
		cin >> h2_max;
		bool major = true;

		for (long j = 1; j < z; ++j) {
			cin >> w1;
			cin >> w2;
			cin >> h1;
			cin >> h2;

			int major_score = 0;

			if (w1_min > w1) {
				w1_min = w1;
				major_score++;
			}

			if (w2_max < w2) {
				w2_max = w2;
				major_score++;
			}

			if (h1_min > h1) {
				h1_min = h1;
				major_score++;
			}

			if (h2_max < h2) {
				h2_max = h2;
				major_score++;
			}

			if (major_score == 4)
				major = true;
			else if (major_score > 0)
				major = false;
		}
		if (major) cout << "TAK";
		else cout << "NIE";
		cout << endl;
	}

	return 0;
}