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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

class Rectangle {
    long int x1,x2,y1,y2;
    public:
           void set_values(long int,long int,long int,long int);  
           void combine(long int,long int,long int,long int);
           long long int area() {return (x2-x1)*(y2-y1);};
} rect;

void Rectangle::set_values(long int a,long int b,long int c,long int d)
{
     x1= a;
     x2= b;
     y1= c;
     y2= d;
}

void Rectangle::combine (long int a,long int b,long int c,long int d)
{
     x1= std::min(x1,a);
     x2= std::max(x2,b);
     y1= std::min(y1,c);
     y2= std::max(y2,d);
}

long long int area(long int a,long int b,long int c,long int d)
{
     return (b-a)*(d-c);
}

int main()
{
ios_base::sync_with_stdio(0);
int t;
vector<string> output;
cin >> t;

for (int j=0; j<t;++j)
{
int n;
long int x1,x2,y1,y2;
long long int a = 0;

Rectangle rect;
rect.set_values(1000000001,0,1000000001,0); 
cin >> n;    

for(int i=0;i<n;++i)
{
      cin >> x1 >> x2 >> y1 >> y2;
      a = max(a,area(x1,x2,y1,y2));
      rect.combine(x1,x2,y1,y2);
} 

if (a == rect.area()) output.push_back("TAK"); else output.push_back("NIE");
}

for (std::vector<string>::iterator itr=output.begin();itr<output.end();++itr)
{
    cout<<*itr<<endl;
}
   
}