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
35
36
37
38
39
#include <cstdio>
#include <algorithm>
#include <vector>
#include<iostream>
#define fru(j,n) for(int j=0;j<n;++j)
#define tr(it,x) for(typeof(x.begin())it=x.begin();it!=x.end();++it)
#define x first
#define y second

using namespace std;
typedef pair<int,int> pii;
typedef long long LL;
const int MAXN = 100005,INF=1000000009;

pii W[MAXN],K[MAXN];
void solve()
{
    int n;
    pii w(INF,-1),k(INF,-1);
    scanf("%d",&n);
    fru(i,n)
        scanf("%d%d%d%d",&W[i].x,&W[i].y,&K[i].x,&K[i].y);
    fru(i,n)
    {
        w.x=min(w.x,W[i].x);w.y=max(w.y,W[i].y);
        k.x=min(k.x,K[i].x);k.y=max(k.y,K[i].y);
    }
    bool ok=false;
    fru(i,n)if(W[i]==w && K[i]==k)ok=true;
    if(ok)puts("TAK");
    else puts("NIE");
}
int main()
{
    int t;
    scanf("%d",&t);
    fru(i,t)solve();
    return 0;
}