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
// Try.cpp : This file contains the 'main' function. Program execution begins and ends there.
//Mateusz Wasilewski

#include <bits/stdc++.h>
using namespace std;
int t, N;
long long expect,got;
long long l, e, g;
long long mine, ming;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> t;
	for (int j = 0; j < t; j++) {
		cin >> N;
		expect = 0;
		got = 0;
		mine = 999999999999;
		ming = 999999999999;
		for (int i = 0; i < N; i++) {
			cin >> l >> g >> e;
			ming = min(ming, g);
			mine = min(mine, e);
			expect += l * e;
			got += l * g;
		}
		if (got == expect && ming <= mine) {
			cout << "TAK" << endl;
		}
		else {
			cout << "NIE" << endl;
		}
	}
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu