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

using namespace std;

int h1[100005], h2[100005], w1[100005], w2[100005];

int main()
{
	ios_base::sync_with_stdio(0);
	int testy;
	bool czy;
	//cin>>testy;
	scanf("%d", &testy);
	while(testy--)
	{
        czy=false;
		int n, h1b=1000000001, h2b=0, w1b=1000000001, w2b=0;
		//cin>>n;
		scanf("%d", &n);
		for(int i=1; i<=n; i++)
		{
         //   cin>>h1[i]>>h2[i]>>w1[i]>>w2[i];
            scanf("%d%d%d%d", &h1[i], &h2[i], &w1[i], &w2[i]);
            h1b=min(h1b, h1[i]);
            h2b=max(h2b, h2[i]);
            w1b=min(w1b, w1[i]);
            w2b=max(w2b, w2[i]);
        }
        for(int i=1; i<=n; i++)
            if (h1[i]==h1b && h2[i]==h2b && w1[i]==w1b && w2[i]==w2b)
                czy=true;
        if (czy)
            printf("TAK\n");
        else
            printf("NIE\n");
	}
	return 0;
}