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

int main() {
	int t,n;
	unsigned int xn,xx, yn, yx, rx, ry;
  unsigned int w1, w2, h1, h2;
  scanf("%d\n", &t);
  while(t--) {
		scanf("%d\n", &n);
		xx = yx = rx = ry = 0;
    xn = yn = 1000000001;
		while(n--) {
		  scanf("%d %d %d %d\n", &w1, &w2, &h1, &h2);
      if(xn>w1) xn=w1;
			if(xx<w2) xx=w2;
			if(yn>h1) yn=h1;
			if(yx<h2) yx=h2; 
      if(rx < w2-w1 && ry < h2-h1) {
				rx=w2-w1;
				ry=h2-h1;
			}
		}
		if(xn+rx >= xx && yn+ry >= yx) printf("TAK\n");
    else printf("NIE\n");
	}
  return 0;
}