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
#include<iostream>
#include<limits>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);

  long t, n;
  long W1, W2, H1, H2;
  long w1, w2, h1, h2;
  bool ok, zmiana;

  cin >> t;
  for(long i = 0; i < t; ++i) {
    cin >> n;
    ok = false;
    W1 = numeric_limits<long>::max(); W2 = 0;
    H1 = numeric_limits<long>::max(); H2 = 0;
    for(long j = 0; j < n; ++j) {
      cin >> w1 >> w2 >> h1 >> h2;
      zmiana = false;
      if(w1 < W1) {W1 = w1; zmiana = true;}
      if(w2 > W2) {W2 = w2; zmiana = true;}
      if(h1 < H1) {H1 = h1; zmiana = true;}
      if(h2 > H2) {H2 = h2; zmiana = true;}
      if(zmiana)
        ok = false;
      if(w1 == W1 && w2 == W2 && h1 == H1 && h2 == H2)
        ok = true;
    }
    cout << (ok ? "TAK" : "NIE") << endl;
  }
  return 0;
}