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
#include <iostream>

using namespace std;

int main()
{
    int testy;
    int firmy;
    int h1, h2;
    int w1, w2;
    int minh, maxh;
    int minw, maxw;
    bool miesci;
    cin>>testy;
    while (testy--)
    {
        maxh=0;
        maxw=0;
        minh=2000000000;
        minw=2000000000;
        cin>>firmy;
        while (firmy--)
        {
            cin>>w1>>w2>>h1>>h2;
            if (minh>h1)
            {
                minh=h1;
                miesci=false;
            }
            if (maxh<h2)
            {
                maxh=h2;
                miesci=false;
            }
            if (minw>w1)
            {
                minw=w1;
                miesci=false;
            }
            if (maxw<w2)
            {
                maxw=w2;
                miesci=false;
            }
            if (minh==h1 && maxh==h2 && minw==w1 && maxw==w2)
            {
                miesci=true;
            }
        }
        if (miesci) cout<<"TAK\n";
        else cout<<"NIE\n";
    }
    return 0;
}