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

int main() {
  int t,n,i,j;
  int w1,w2,h1,h2,min_w1, max_w2, min_h1, max_h2;
  int major;
  scanf("%d", &t);
  for (i=0; i<t; ++i) {
    scanf("%d", &n);
    min_w1=min_h1=1000000001;
    max_w2=max_h2=0;
    major=0;
    for (j=0; j<n; ++j) {
      scanf("%d %d %d %d", &w1, &w2, &h1, &h2);
      if (min_w1>w1) {min_w1=w1; major=0;}
      if (max_w2<w2) {max_w2=w2; major=0;}
      if (min_h1>h1) {min_h1=h1; major=0;}
      if (max_h2<h2) {max_h2=h2; major=0;}
      if (min_w1==w1 && max_w2==w2 && min_h1==h1 && max_h2==h2) major=1;
    }
    if (major)
      printf("TAK\n");
    else
      printf("NIE\n");
  }
  return 0;
}