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<algorithm>
#define st first
#define nd second
using namespace std;
void f(){
    int n;
    scanf("%d",&n);
    pair<int,int>a[n],b[n];
    pair<int,int>w1,w2;
    w1=w2=make_pair(1000000000,0);
    for(int i=0;i<n;i++)scanf("%d%d%d%d",&a[i].st,&a[i].nd,&b[i].st,&b[i].nd);
    for(int i=0;i<n;i++){
        w1.st=min(w1.st,a[i].st);
        w1.nd=max(w1.nd,a[i].nd);
        w2.st=min(w2.st,b[i].st);
        w2.nd=max(w2.nd,b[i].nd);
    }
    for(int i=0;i<n;i++){
        if(w1==a[i]&&w2==b[i]){printf("TAK\n");return;}
    }
    printf("NIE\n");
}
main(){
    int t;
    scanf("%d",&t);
    while(t--)f();
}