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
66
67
68
69
70
71
72
#include <iostream>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    int t;
    cin >> t;

    int n;

    for(int p=0; p<t; p++)
    {
        cin >> n;

        unsigned long *w1 = new unsigned long  [n];
        unsigned long *w2 = new unsigned long  [n];
        unsigned long *h1 = new unsigned long  [n];
        unsigned long *h2 = new unsigned long  [n];
        unsigned long mw1, mw2, mh1, mh2;
        int i=0;

        cin >> w1[i] >> w2[i] >> h1[i] >> h2[i] ;

        mw1 = w1[i];
        mw2 = w2[i];
        mh1 = h1[i];
        mh2 = h2[i];

        int indeks = -1;

        for(i=1; i<n; i++)
        {
            cin >> w1[i] >> w2[i] >> h1[i] >> h2[i] ;
            if(w1[i] < mw1)
                mw1 = w1[i];
            if(w2[i] > mw2)
                mw2 = w2[i];
            if(h1[i] < mh1)
                mh1 = h1[i];
            if(h2[i] > mh2)
                mh2 = h2[i];

            if((w1[i] <= mw1 && h1[i] <= mh1) && (w2[i] >= mw2 && h2[i] >= mh2))
            {
                mw1 = w1[i];
                mh1 = h1[i];
                mw2 = w2[i];
                mh2 = h2[i];
                indeks = i;
            }
        }

        if(indeks == -1)
        {
            i=0;
            if((w1[i] <= mw1 && h1[i] <= mh1) && (w2[i] >= mw2 && h2[i] >= mh2))
                cout << "TAK\n";
            else
                cout << "NIE\n";
        }
        else
            cout << "TAK\n";

        delete []w1;
        delete []w2;
        delete []h1;
        delete []h2;
    }
    return 0;
}