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
#include <iostream>
using namespace std;
int main() {
    int t;
    cin >> t;
    for(int i = 0; i < t; i++) {
	int n;
	cin >> n;
	int tab[n][4];
	int min_w = 1000000000, max_w = 0, min_h = 1000000000, max_h = 0;
	for(int j = 0; j < n; j++) {
	    int w1, w2, h1, h2;
	    cin >> w1 >> w2 >> h1 >> h2;
	    tab[j][0] = w1;
	    tab[j][1] = w2;
	    tab[j][2] = h1;
	    tab[j][3] = h2;
	    if(w1 < min_w) min_w = w1;
	    if(w2 > max_w) max_w = w2;
	    if(h1 < min_h) min_h = h1;
	    if(h2 > max_h) max_h = h2;
	}
	int major = 0;
	for(int j = 0; j < n; j++) {
	    if((tab[j][0] == min_w) && (tab[j][1] == max_w) &&
	    (tab[j][2] == min_h) && (tab[j][3] == max_h)) {
		major++;
	    }
	}
	if(major > 0) cout << "TAK" << endl;
	else  cout << "NIE" << endl;
    }
}