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

typedef unsigned int uint;
#define REP(i,n) for(uint i = 0; i < uint(n); i += 1)

struct Lus {
  uint w1;
  uint w2;
  uint h1;
  uint h2;
};

bool operator==(Lus a, Lus b) {
  return
      a.w1 == b.w1 &&
      a.w2 == b.w2 &&
      a.h1 == b.h1 &&
      a.h2 == b.h2;
}

void Print(Lus m) {
  cout
      << m.w1 << " "
      << m.w2 << " "
      << m.h1 << " "
      << m.h2 << endl;
}

void Solve() {
  int n;
  cin >> n;
  vector<Lus> v(n);
  Lus m = {-1, 0, -1, 0};
  // Print(m);
  REP(i, n) {
    cin >> v[i].w1 >> v[i].w2 >> v[i].h1 >> v[i].h2;
    m.h1 = min(m.h1, v[i].h1);
    m.w1 = min(m.w1, v[i].w1);
    m.h2 = max(m.h2, v[i].h2);
    m.w2 = max(m.w2, v[i].w2);
    // Print(v[i]);
    // Print(m);
    // cout << endl;
  }
  REP(i,n) {
    if (v[i] == m) {
      cout << "TAK" << endl;
      return;
    }
  }
  cout << "NIE" << endl;
}

int main () {
  int n;
  cin >> n;
  REP(i, n) Solve();
}