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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <cstdio>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

const int INF = 1 << 30;
const double EPS = 1e-12;

void solve()
{
    int n;
    scanf("%d", &n);
    int minx=INF, maxx=0, miny=INF, maxy=0;
    vector<pair<pii, pii> > v(n);
    for(int i=0; i<n; i++)
    {
        scanf("%d %d %d %d", &v[i].fi.fi, &v[i].se.fi, &v[i].fi.se, &v[i].se.se);
        maxx=max(maxx, v[i].se.fi);
        minx=min(minx, v[i].fi.fi);
        maxy=max(maxy, v[i].se.se);
        miny=min(miny, v[i].fi.se);
    }
    int ans=0, git=1;
    for(int i=0; i<n; i++)
    {
        if(v[i]==mp(mp(minx,miny), mp(maxx,maxy))) ans=1;
    }
    if(ans) printf("TAK\n");
    else printf("NIE\n");
}

int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        solve();
    }
}