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

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

int main(){
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  for(int k=0; k<t; k++){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
      cin >> w1[i] >> w2[i] >> h1[i] >> h2[i];
    }
    int minw=1000000005;
    int minh=1000000005;
    int maxw=-1;
    int maxh=-1;
    for(int i=0; i<n; i++){
      if(minw>w1[i]) minw=w1[i];
      if(minh>h1[i]) minh=h1[i];
      if(maxw<w2[i]) maxw=w2[i];
      if(maxh<h2[i]) maxh=h2[i];
    }
    bool a=false;
    for(int i=0; i<n; i++){
      if(w1[i]==minw && w2[i]==maxw && h1[i]==minh && h2[i]==maxh){
        a=true;
        break;
      }
    }
    if(a==false) cout << "NIE" << endl;
    else cout << "TAK" << endl;
  }
  return 0;
}