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

int main()
{
        int t, n;
        int i, j;
        int w1, w2, h1, h2;
        int w1_min, w2_max, h1_min, h2_max;
        int may;

        scanf("%d\n", &t);
        for(i = 0; i < t; ++i) {
                may = 1;
                scanf("%d\n", &n);
                scanf("%d %d %d %d\n", &w1, &w2, &h1, &h2);
                w1_min = w1;
                w2_max = w2;
                h1_min = h1;
                h2_max = h2;
                for(j = 1; j < n; ++j) {
                        scanf("%d %d %d %d\n", &w1, &w2, &h1, &h2);
                        if (w1 <= w1_min && w2 >= w2_max && h1 <= h1_min && h2 >= h2_max) {
                                may = 1;
                                w1_min = w1;
                                w2_max = w2;
                                h1_min = h1;
                                h2_max = h2;
                                //if (i == 3) {
                                //        printf("%d %d %d %d\n", w1_min, w2_max, h1_min, h2_max);
                                //}
                                continue;
                        }
                        if (w1 < w1_min) {
                                may = 0;
                                w1_min = w1;
                        }
                        if (w2 > w2_max) {
                                may = 0;
                                w2_max = w2;
                        }
                        if (h1 < h1_min) {
                                may = 0;
                                h1_min = h1;
                        }
                        if (h2 > h2_max) {
                                may = 0;
                                h2_max = h2;
                        }
                }
                if (may == 1) {
                        printf("TAK\n");
                } else {
                        printf("NIE\n");
                }
                //if (i == 3) {
                //        printf("MIN/MAX %d %d %d %d\n\n", w1_min, w2_max, h1_min, h2_max);
                //}
        }
        return 0;
}