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
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define e1 first
#define e2 second
#define For(a, b, i) for(int i=a;i<b; ++i)
#define Dfor(a, b, i) for(int i=a;i>=b; --i)
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> pp;
const int mod=1e9+7;
const int inf=1e9+9;
const int mod69=1e9+696969;
#define maxn 110
int t[maxn][3],n,m;
pii p[maxn],k[maxn];
vector <int> proc[maxn];
void wczytaj()
{
	scanf("%d%d", &n, &m);
	For(0, n, i) scanf("%d%d%d", &t[i][0], &t[i][1], &t[i][2]);
}
void tworz()
{
	For(0, n, i)
	{
		p[i].e1=t[i][0];
		p[i].e2=t[i][1]-t[i][2];
		k[i].e1=t[i][0]+t[i][2];
		k[i].e2=t[i][1];
		////printf("%d %d\n%d %d\n\n", p[i].e1, p[i].e2, k[i].e1, k[i].e2);
	}
}
bool czy(int r, int akt)
{
	//bool q=true;
	int w=0;
	For(0, (int) proc[r].size(), i)
	{
		if((p[proc[r][i]].e2>k[akt].e1) || (k[proc[r][i]].e1<p[akt].e2)) w++;
	}
	///printf("%d %d %d %d\n", r, proc[r].size(), akt, w);
	if(w==(int) proc[r].size()) {proc[r].pb(akt);return true;}
	else return false;
}
int main()
{
	wczytaj();
	tworz();
	///bool q=true;
	For(0, n, i)
	{
		For(0, m, j)
		{
			if(czy(j, i)==true) break;
		}
		/*printf("%d\n", i);
		For(0, (int) m, j) {printf("%d %d\n", j, (int) proc[j].size());}
		puts("\n");*/
	}
	int wyn=0;
	For(0, m , i)
	{
		wyn+=(int) proc[i].size();
	}
	if(wyn==n) puts("TAK");
	else puts("NIE");
	
}