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
#include <stdio.h>

#define rozm 1000002

int main()
{
  int d, n, w1[rozm], w2[rozm], h1[rozm], h2[rozm];
  int i, minw1, maxw2, minh1, maxh2;
  scanf("%d", &d);
  while (d--)
  {
    scanf("%d",&n);
    for (i=0; i<n; i++) scanf("%d%d%d%d", &w1[i], &w2[i], &h1[i], &h2[i]);
    minw1 = w1[0];
    maxw2 = w2[0];
    minh1 = h1[0];
    maxh2 = h2[0];
    for (i=1; i<n; i++)
    {
      if (minw1 > w1[i]) minw1 = w1[i];
      if (maxw2 < w2[i]) maxw2 = w2[i];
      if (minh1 > h1[i]) minh1 = h1[i];
      if (maxh2 < h2[i]) maxh2 = h2[i];
    }

    int jest = 0;
    for (i=1; i<n; i++)
      if (minw1==w1[i] && maxw2==w2[i] && minh1==h1[i] && maxh2==h2[i]) jest = 1;

    if (jest) printf("TAK\n"); else printf("NIE\n");

  }
  return 0;
}