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
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Krzysztof Baranski
////////////////////////////////////////////////////////////////////
//                                                                //
//                           HEADERS                              //
//                                                                //
//////////////////////////////////////////////////////////////////// 
// includes
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <complex>
#include <iterator>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <cstdlib>
using namespace std;
// defines
#define FOR(x,b,e) for(int x=b; x<=(e); ++x)
#define FORD(x,b,e) for(int x=(b); x>=(e); --x)
#define FORK(x,b,e,k) for(int x=b; x<=(e); x+=k)
#define REP(x,n) for(int x=0; x<(n); ++x)
#define VAR(v,n) decltype(n) v=(n)
#define ALL(c) c.begin(),c.end()
#define SIZE(x) (int)x.size()
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define CLEAR(x) while(!(x).empty())(x).pop()
#define PB push_back
#define MP make_pair
#define ND second
#define ST first
#define POP(q) q.top(); q.pop()

#define __START__ int __z_;scanf("%d\n",&__z_);while(__z_--){
#define __STOP__ }return 0;
#define _INT(x) int x; scanf("%d",&x) 
// typedef
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<bool> VB;
typedef stack<int> SI;
typedef pair<int,int> PII;
typedef stack<PII> SPII;
typedef vector<char> VC;
typedef vector<VC> VVC;
// consts
const int INF = 1000000001;
const long long LINF = 1000000000000000001;
const double EPS = 10e-9;
////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------//
////////////////////////////////////////////////////////////////////

struct Mirror {
	int w1,w2,h1,h2;
	
	Mirror(LL w1,LL w2,LL h1,LL h2):w1(w1),w2(w2),h1(h1),h2(h2){}
	Mirror& operator=(const Mirror& m) {w1=m.w1;w2=m.w2;h1=m.h1;h2=m.h2;return *this;}
	
	bool In(const Mirror& m) const {
		return m.w1<=w1 && m.w2>=w2 && m.h1<=h1 && m.h2>=h2;
	}
	
};

bool operator<(const Mirror&m1,const Mirror&m2) {
	if(m1.w2<m2.w2) return true;
	else if(m1.w2==m2.w2 && m1.h2<m2.h2) return true;
	else if(m1.w2==m2.w2 && m1.h2==m2.h2 && m1.w1>m2.w1) return true;
	else if(m1.w2==m2.w2 && m1.h2==m2.h2 && m1.w1==m2.w1 && m1.h1>m2.h1) return true;
	else return false;
}

bool operator==(const Mirror&m1,const Mirror&m2) {
	return m2.w1==m1.w1 && m2.w2==m1.w2 && m2.h1==m1.h1 && m2.h2==m1.h2;
}

bool operator<=(const Mirror&m1,const Mirror&m2) {
	return (m1<m2) || (m1==m2);
}



//==================================================================| MAIN
int main() {	
	__START__

	_INT(n);
	
	vector<Mirror> factories;
	
	REP(i,n) {
		int w1,w2,h1,h2;
		scanf("%d %d %d %d",&w1,&w2,&h1,&h2);
		factories.emplace_back(w1,w2,h1,h2);
	}
	
	sort(ALL(factories));
	
	bool ok=true;
	FORD(i,n-2,0) {
		if(!factories[i].In(factories[n-1])) {ok=false;break;} 
	}
	
	if(ok) printf("TAK\n");
	else printf("NIE\n");
	
	__STOP__
}