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
//Przemysław Jakub Kozłowski
#include <iostream>
#include <cstdio>
#include <algorithm>
#define FI first
#define SE second
#define MP make_pair
using namespace std;
const int N = 100005;

int t;
int n;
pair<pair<int,int>,pair<int,int> > tab[N];
int wmin, wmax, hmin, hmax;

int main()
{
    scanf("%d", &t);
    for(int ti = 1;ti <= t;ti++)
    {
        scanf("%d", &n);
        for(int i = 1;i <= n;i++)
            scanf("%d%d%d%d", &tab[i].FI.FI, &tab[i].FI.SE, &tab[i].SE.FI, &tab[i].SE.SE);

        wmin = tab[1].FI.FI;
        hmin = tab[1].SE.FI;
        wmax = tab[1].FI.SE;
        hmax = tab[1].SE.SE;
        for(int i = 1;i <= n;i++)
        {
            wmin = min(wmin, tab[i].FI.FI);
            hmin = min(hmin, tab[i].SE.FI);
            wmax = max(wmax, tab[i].FI.SE);
            hmax = max(hmax, tab[i].SE.SE);
        }

        bool wyn = false;
        for(int i = 1;i <= n;i++)
            if(tab[i].FI.FI == wmin && tab[i].FI.SE == wmax && tab[i].SE.FI == hmin && tab[i].SE.SE == hmax)
            {
                wyn = true;
                break;
            }

        if(wyn) printf("TAK\n");
        else printf("NIE\n");
    }
    return 0;
}