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

int w1[100000];
int w2[100000];
int h1[100000];
int h2[100000];

int main()
{
    int test, n;
    scanf("%d", &test);
    while(test--)
    {
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	    scanf("%d %d %d %d", w1 + i, w2 + i, h1 + i, h2 + i);
	bool ok = false;
	int W1 = *min_element(w1, w1 + n), W2 = *max_element(w2, w2 + n),
	    H1 = *min_element(h1, h1 + n), H2 = *max_element(h2, h2 + n);
	for(int i = 0; i < n; i++)
	    if(w1[i] == W1 && w2[i] == W2 && h1[i] == H1 && h2[i] == H2)
	    {
		ok = true;
		break;
	    }
	puts(ok ? "TAK" : "NIE");
    }
}