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

using namespace std;

const int MIN_K = 1000000009;
const int MAX_K = -1;

struct four {
  int w1,w2,h1,h2;
};

int main(int argc, char *argv[]) {  
  int t,n,a,b,c,d;
  
  scanf("%d", &t);
  while(t--) {
    int w1=MIN_K,w2=MAX_K,h1=MIN_K,h2=MAX_K;
    vector<four> res;
    bool odp=false;
    
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
      scanf("%d%d%d%d",&a,&b,&c,&d);
      w1 = min(w1,a);
      w2 = max(w2,b);
      h1 = min(h1,c);
      h2 = max(h2,d);
      
      four f; f.w1=a; f.w2=b; f.h1=c; f.h2=d;
      res.push_back(f);
    }
    
    for(int i=0; i<n; i++) {
      if(res[i].w1<=w1 && res[i].w2>=w2 && res[i].h1<=h1 && res[i].h2>=h2) 
        odp=true;
        
      if(odp) break;
    }
    
    if(odp) puts("TAK");
    else puts("NIE");
  }
  
  return 0;
}