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

using namespace std;

struct mir
{
    int x_down;
    int x_up;
    int y_down;
    int y_up;
};
//__attribute__((aligned(32)));

int main()
{
    int ttt;
    scanf("%d",&ttt);
    while ( ttt-- )
          {
              int n;
              scanf("%d",&n);
              
              struct mir _m = { 1000000009, 0, 1000000009, 0 };
              int last_m = 0;
              
              while ( n-- )
                  {
                      struct mir m_test;
                      scanf( "%d%d%d%d",&m_test.x_down, &m_test.x_up, &m_test.y_down, &m_test.y_up );
                      
                      if ( _m.x_down > m_test.x_down )
                         { _m.x_down = m_test.x_down; last_m=-1; }
                      if ( _m.x_up < m_test.x_up )
                         { _m.x_up = m_test.x_up; last_m=-1; }
                      if ( _m.y_down > m_test.y_down )
                         { _m.y_down = m_test.y_down; last_m=-1; }
                      if ( _m.y_up < m_test.y_up )
                         { _m.y_up = m_test.y_up; last_m=-1; }
                      
                      //printf("%d %d %d %d\n",_m.x_down,_m.x_up,_m.y_down,_m.y_up);
                      //printf("%d %d %d %d\n",m_test.x_down,m_test.x_up,m_test.y_down,m_test.y_up);
                      //printf("\n");
                      
                      if ( !memcmp( &_m, &m_test, sizeof(m_test) ) )
                         {
                             last_m = 0;
                             //printf("aaaa\n");
                         }
                  }
              
              //printf("%d %d %d %d\n",_m.x_down,_m.x_up,_m.y_down,_m.y_up);
              
              if ( last_m )
                  printf("NIE\n");
                 else printf("TAK\n");
          }
    
    return 0;
}