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
#include <iostream>
#include <vector>
using namespace std;
const int OO = (1<<30)-1;

bool solve() {
  int n;
  scanf("%d", &n);
  vector<int> w1(n), w2(n), h1(n), h2(n);
  int wMin = OO;
  int wMax = 0;
  int hMin = OO;
  int hMax = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]);
    wMin = min(wMin, w1[i]);
    wMax = max(wMax, w2[i]);
    hMin = min(hMin, h1[i]);
    hMax = max(hMax, h2[i]);
  }

  for (int i = 0; i < n; ++i) {
    if (w1[i] == wMin and w2[i] == wMax and h1[i] == hMin and h2[i] == hMax)
      return true;
  }
  return false;
}

int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    if (solve()) printf("TAK\n");
    else printf("NIE\n");
  }
  return 0;
}