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
#include <stdio.h>
#include <iostream>
using namespace std;
int main( int argc, const char* argv[] )
{
	int t, n, i, k, w1min, h1min, w2max, h2max, w1, w2, h1, h2, w1pam, w2pam, h1pam, h2pam;
	cin >> t;

	for (i = 0; i < t; i++) {
			
			cin >> n;
			
			cin >> w1min;
			cin >> w2max;
			cin >> h1min;
			cin >> h2max;
			
			w1pam=0; w2pam=0; h1pam=0; h2pam=0;
			
			for (k = 1; k < n; k++) {
				cin >> w1;
				cin >> w2;
				cin >> h1;
				cin >> h2;
				
								if(w1<w1min) {w1min = w1;}
				if(w2>w2max) {w2max = w2;}
				if(h1<h1min) {h1min = h1;}
				if(h2>h2max) {h2max = h2;}
				
				if(w1 == w1min && w2 == w2max && h1 == h1min && h2 == h2max) {
					w1pam=w1min; w2pam=w2max; h1pam=h1min; h2pam=h2max;
				}
			}
			if(w1pam==w1min && w2pam==w2max && h1pam==h1min && h2pam==h2max) {
				cout << "TAK" << endl;
			}
			else {
				cout << "NIE" << endl;
			}
		}
}