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
/*****************************************************************************
* ZADANIE : Lustra (runda 1B)                                                *
* AUTOR   : Lukasz Kierat                                                    *
*****************************************************************************/
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  int i, t, n, minw, maxw, minh, maxh, tab[200000][4];

  scanf ("%d", &t);
  while (t--) {
    minw = minh = 1000000001;
    maxw = maxh = 0;
    scanf ("%d", &n);
    for (i = 0; i < n; ++i) {
      scanf ("%d%d%d%d", &tab[i][0], &tab[i][1], &tab[i][2], &tab[i][3]);
      minw = min(minw, tab[i][0]);
      maxw = max(maxw, tab[i][1]);
      minh = min(minh, tab[i][2]);
      maxh = max(maxh, tab[i][3]);
    }
    for (i = 0; i < n; ++i)
      if (minw == tab[i][0] && maxw == tab[i][1] &&
          minh == tab[i][2] && maxh == tab[i][3])
        break;
    printf ("%s\n", i < n ? "TAK" : "NIE");
  }

  return 0;
}