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

int main()
{
    int t; scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        int n; scanf("%d", &n);
        int max1, max2, k1, k2;
        max1 = max2 = k1 = k2 = -1; 
        for (int j = 0; j < n; j++) {
            int w1, w2, h1, h2;
            scanf("%d %d %d %d", &w1, &w2, &h1, &h2);
            if (w2 - w1 >= max1) { 
                   max1 = w2 - w1; k1 = j; 
            }
            if (h2 - h1 >= max2) {
                    max2 = h2 - h1; k2 = j;
            }
        }
        
        if (k1 == k2)
           puts("TAK");
        else
            puts("NIE");
    }
    //system("PAUSE");
    return 0;
}