#P5980. [PA 2019] Herbata
[PA 2019] Herbata
Description
You have infinitely many cups with unlimited capacity and cups of water. The -th cup has volume and temperature .
You can perform infinitely many operations. Each operation is one of the following:
-
Choose one cup of water. Suppose its volume is and its temperature is . You may pour it into several empty cups so that the temperature of water in each cup is still , and the sum of their volumes equals . Note that the volumes can be any non-negative real numbers.
-
Choose two cups of water. Suppose one has volume and temperature , and the other has volume and temperature . You may mix them into one cup of water with volume and temperature .
Your goal is to perform some operations so that after all operations, for every , the -th cup has volume and temperature . Write a program to determine whether a solution exists.
Input Format
The first line contains a positive integer , denoting the number of testdata.
For each testdata, the first line contains a positive integer .
The next lines each contain three positive integers .
Output Format
For each testdata, output one line. If a solution exists, output TAK; otherwise, output NIE.
5
2
2 1 4
2 5 2
2
1 4 3
1 5 4
2
1 5 7
1 7 5
2
1 4 1
1 2 5
3
2 6 4
1 2 3
3 4 5
TAK
NIE
TAK
NIE
TAK
Hint
For of the testdata, , , . The input guarantees that the sum of all does not exceed across all testdata.
Translated by ChatGPT 5
京公网安备 11011102002149号