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 <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin>>t;
    
    for(int i = 0; i < t; i++) {
	int n;
	cin>>n;
	vector <int> w1(n), w2(n), h1(n), h2(n);
	int minW = INT_MAX, maxW = -INT_MAX, minH = INT_MAX, maxH = -INT_MAX;
	for(int j = 0; j < n; j++) {
	    cin>>w1[j]>>w2[j]>>h1[j]>>h2[j];
	    minW = min(minW,w1[j]);
	    maxW = max(maxW,w2[j]);
	    minH = min(minH,h1[j]);
	    maxH = max(maxH,h2[j]);
	}
	bool ok = false;
	for(int j = 0; j < n; j++) {
	    if(w1[j] == minW && w2[j] == maxW && h1[j] == minH && h2[j] == maxH) {
		ok = true;
		break;
	    }
	}
	if(ok)
	    cout<<"TAK"<<endl;
	else
	    cout<<"NIE"<<endl;
    }
    
}