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
#include <iostream>

using namespace std;

int main(){

ios_base::sync_with_stdio(0);
	int l_testy;
	cin >> l_testy;
	for(int test = 0 ; test < l_testy ; test++){
		int top = -1, bottom = 1000000001, left = 1000000001, right = -1, l_firm;
		cin >> l_firm;
		bool wygrywa = true; 
		for(int firma = 0 ; firma < l_firm ; firma++){
			int l_top, l_bottom, l_left, l_right;
			cin >> l_left >> l_right >> l_bottom >> l_top;
			int l_zmian = 0, l_rownych = 0;
			if(l_top >= top){
				if(l_top == top) l_rownych++;
				top = l_top;
				l_zmian++;
			}
			if(l_right >= right){
				if(l_right == right) l_rownych++;
				right = l_right;
				l_zmian++;
			}
			if(l_bottom <= bottom){
				if(l_bottom == bottom) l_rownych++;
				bottom = l_bottom;
				l_zmian++;
			}
			if(l_left <= left){
				if(l_left == left) l_rownych++;
				left = l_left;
				l_zmian++;
			}
			if(l_zmian == 4) wygrywa = true;
			else if(l_zmian - l_rownych > 0) wygrywa = false;
			//cout << "zmian = " << l_zmian << " rownych = " << l_rownych << "\n";
		}
	if(wygrywa) cout << "TAK\n";
	else cout << "NIE\n";
	}
}