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
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
	int n, m, p, k, c;
	int minP = 1000000;
	int maxK = 0;
	long long int sum = 0;

	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++)
	{
		scanf("%d %d %d", &p, &k, &c);

		minP = min(minP, p);
		maxK = max(maxK, k);
		sum += c;
	}

	long long int sum2 = m;
	sum2 *= maxK - minP;

	if (sum > 0.9 * sum2)
		printf("NIE");
	else
		printf("TAK");

	return 0;
}