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
#include <iostream>
using namespace std;

int main() {

    int t;
    cin >> t;
    bool wyn[t];
    for (int i = 0; i < t; i++) {
        wyn[i] = false;
        int n;
        cin >> n;
        int tab[n+1][4];
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < 4; k++) {
                cin >> tab[j][k];
            }
            if (j == 0 || tab[j][0] < tab[n][0]) tab[n][0] = tab[j][0];
            if (j == 0 || tab[j][1] > tab[n][1]) tab[n][1] = tab[j][1];
            if (j == 0 || tab[j][2] < tab[n][2]) tab[n][2] = tab[j][2];
            if (j == 0 || tab[j][3] > tab[n][3]) tab[n][3] = tab[j][3];
        }
        for (int j = 0; j < n; j++) {
            int ile = 0;
            for (int k = 0; k < 4; k++) {
                if (tab[j][k] == tab[n][k]) {
                    ile++;
                }
            }
            if (ile == 4) {
                wyn[i] = true;
                break;
            }
        }
    }
    for (int i = 0; i < t; i++) {
        if (wyn[i]) cout << "TAK\n";
        else cout << "NIE\n";
    }
}