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
#include<iostream>
#include<vector>
#include<cstdio>
#include<cmath>
using namespace std;
vector <pair <int, int> > W;
vector <pair <int, int> > H;
main()
{
	int t, n;
	scanf("%u", &t);
	while(t--){
				scanf("%u", &n);
				int w1, w2, h1, h2;
				int Wmax=0, Wmin=2000000000, Hmax=0, Hmin=2000000000;
				for(int i=0; i<n; i++){
									//cin>>w1>>w2>>h1>>h2;
									scanf("%u%u%u%u", &w1, &w2, &h1, &h2);
									W.push_back(make_pair(w1, w2) );
									H.push_back(make_pair(h1, h2) );
									if(w1<Wmin) Wmin=w1;
									if(w2>Wmax) Wmax=w2;
									if(h1<Hmin) Hmin=h1;
									if(h2>Hmax) Hmax=h2;
								}
				bool czy=false;
				for(int i=0; i<n; i++)
							{
							if(W[i].first<=Wmin && W[i].second>=Wmax && H[i].first<=Hmin && H[i].second>=Hmax){ czy=true; break; }
							}
				if(czy) printf("TAK\n");
				else printf("NIE\n");
				H.clear();
				W.clear();
			}
		}