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
#include <stdio.h>


int main()
{
    int t;
    scanf("%d", &t);    
    while (t--)
    {
        int n;
        scanf("%d", &n);
        int min_w, min_h, max_w, max_h;
        int have_major = 1;
        scanf("%d %d %d %d", &min_w, &max_w, &min_h, &max_h);
        --n;
        while (n--)
        {
            int t_min_w, t_min_h, t_max_w, t_max_h;
            scanf("%d %d %d %d", &t_min_w, &t_max_w, &t_min_h, &t_max_h);            
            int major = 0;
            if (t_min_w <= min_w && t_max_w >= max_w
                && t_min_h <= min_h && t_max_h >= max_h)
                major = 1;

            int larger = 0;
            if (t_min_w < min_w) {
                min_w = t_min_w;
                larger = 1;
            }
            if (t_max_w > max_w) {
                max_w = t_max_w;
                larger = 1;
            }
            if (t_min_h < min_h) {
                min_h = t_min_h;
                larger = 1;
            }
            if (t_max_h > max_h) {
                max_h = t_max_h;
                larger = 1;
            }

            if (major)
                have_major = 1;
            else if (larger)
                have_major = 0;
        }
        printf("%s\n", have_major ? "TAK" : "NIE");

    }
    return 0;
}