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
/*************************************************************************
 *                                                                       *
 *                   Potyczki Algorytmiczne 2014                         *
 *                                                                       *
 *                  Zadanie:           Lustra [B]                        *
 *                  Autor:             Jakub Sroka                       *
 *                                                                       *
 *************************************************************************/

#include <cstdio>
#include <vector>

using namespace std;

int main(int argc, const char * argv[])
{
    int nrOfCases, n, minW, maxW, minH, maxH;
    vector<int> w1;
    vector<int> w2;
    vector<int> h1;
    vector<int> h2;
    
    scanf("%d", &nrOfCases);
    
    for (int i=0; i<nrOfCases; i++) {
        scanf("%d", &n);
        
        w1.resize(n), w2.resize(n), h1.resize(n), h2.resize(n);
        
        for (int j=0; j<n; j++) {
            scanf("%d %d %d %d", &w1[j], &w2[j], &h1[j], &h2[j]);
        }
        
        minW = w1[0], maxW = w2[0], minH = h1[0], maxH = h2[0];
        
        for (int j=1; j<n; j++) {
            if (w1[j] < minW) minW = w1[j];
            if (w2[j] > maxW) maxW = w2[j];
            if (h1[j] < minH) minH = h1[j];
            if (h2[j] > maxH) maxH = h2[j];
        }
        
        bool is = false;
        
        for (int j=0; j<n; j++) {
            if (w1[j] == minW && w2[j] == maxW && h1[j] == minH && h2[j] == maxH) {
                printf("TAK\n");
                is = true;
                break;
            }
        }
        
        if (!is) {
            printf("NIE\n");
        }
        
        w1.resize(0), w2.resize(0), h1.resize(0), h2.resize(0);
    }

    return 0;
}