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
#include <cstdio>
#include <algorithm>
const int MAX = 100000;
const int INF = 2000000000;
using namespace std;
struct L
{
    int w1, w2, h1, h2;
};
int main()
{
    int n;
    L t[MAX];
    int tests;
    scanf("%d", &tests);
    while(tests--)
    {
        scanf("%d", &n);
        for(int i = 0; i < n; ++i)
            scanf("%d%d%d%d", &t[i].w1, &t[i].w2, &t[i].h1, &t[i].h2);
        int wmin = INF, wmax = 0, hmin =  INF, hmax = 0;
        for(int i = 0; i < n; ++i)
        {
            wmin = min(wmin, t[i].w1);
            wmax = max(wmax, t[i].w2);
            hmin = min(hmin, t[i].h1);
            hmax = max(hmax, t[i].h2);
        }
        bool f = false;
        for(int i = 0; i < n; ++i)
        {
            if(t[i].w1 <= wmin && t[i].w2 >= wmax && t[i].h1 <= hmin && t[i].h2 >= hmax)
            {
                f = true;
                break;
            }
        }
        if(f)
            printf("TAK\n");
        else
            printf("NIE\n");
    }
    return 0;
}