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
57
58
59
60
61
62
63
64
65
//
//  main.cpp
//  PA_2014_LUS
//
//  Created by Michal Kowalski on 12/05/14.
//  Copyright (c) 2014 Michal Kowalski. All rights reserved.
//

#include <iostream>
#include <stdlib.h>
#include <functional>
#include <vector>
#include <set>

#define MAX_N 100005

using namespace std;
int t,n;

unsigned int w1[MAX_N],w2[MAX_N],h1[MAX_N],h2[MAX_N];

int main()
{
    scanf("%d",&t);
    for (int i=0;i<t;++i)
    {
        scanf("%d",&n);
        set<unsigned int> S;
        set<unsigned int> Sw;
        set<unsigned int> Sh;
        for(int j=0;j<n;++j)
        {
            scanf("%d %d %d %d",&w1[j],&w2[j],&h1[j],&h2[j]);
        }
        ///find min_w1
        unsigned int curMinW = w1[0];
        unsigned int curMaxW = w2[0];
        unsigned int curMinH = h1[0];
        unsigned int curMaxH = h2[0];
        for (int a = 1; a < n; ++a)
        {
            curMinW = min(curMinW,w1[a]);
            curMinH = min(curMinH,h1[a]);
            curMaxW = max(curMaxW,w2[a]);
            curMaxH = max(curMaxH,h2[a]);
        }
        
        bool found = false;
        for (int a = 0; a < n; ++a)
        {
            if (curMinW==w1[a] && curMinH==h1[a] && curMaxW==w2[a] && curMaxH==h2[a])
            {
                found = true;
                break;
            }
        }
        
        if (!found)
            printf("NIE\n");
        else
            printf("TAK\n");

    }
    return 0;
}