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

using namespace std;

int main(int argc, char *argv[])
{

    int w1, w2, h1, h2;
    int t;
    int n;
    cin.sync_with_stdio(false);
    cin >> t;
    for (int i = 0; i < t; i++){
        int min1 = 1000000001;
        int min2 = 1000000001;
        int max1 = 0;
        int max2 = 0;
        bool jedno = false;
        cin >> n;
        for (int j = 0; j < n; j++){
            cin >> w1;
            cin >> w2;
            cin >> h1;
            cin >> h2;
            if (w1 < min1){
                   min1 = w1;
                   jedno = false;
            }
            if (w2 > max1){
                   max1 = w2;
                   jedno = false;
            }
            if (h1 < min2){
                   min2 = h1;
                   jedno = false;
            }
            if (h2 > max2){
                   max2 = h2;
                   jedno = false;
            }
            if (w1 <= min1 && w2 >= max1 && h1 <= min2 && h2 >= max2) jedno = true;  
        }
        if (jedno == true) {
                  cout << "TAK" << endl;
        }
        else {
             cout << "NIE" << endl;
        }
    
    }
    return EXIT_SUCCESS;
}