In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
Byteman is preparing for the final round of an individual programming contest. During his preparation, he has read both the terms and conditions and organizational rules very carefully and discovered that there will be exactly tasks in the final round and each of those tasks will be from one of topics. There can be multiple tasks from the same topic. Byteman knows well all participants of the final round and for each participant he can say what is her skill in each field. Skill is expressed as a positive integer, the greater it is, the higher the skill.
Each task in the final round will have a certain difficulty, represented by a positive integer. Byteman assumes that a task will be solved only by those contestants, whose skill is no less than the difficulty of the task. For each solved task a contestant scores a number of points equal to the difference between her skill and the difficulty of the task. The final ranking is based on the number of the tasks solved (a contestant who solves more tasks is always ranked higher than someone who solves less). Contestants with the same number of tasks solved are sorted basing on their numbers of points (the more points one scores, the higher she is ranked).
Byteman, instead of training hard, started to think whether there exists such a problemset for which he will win. He has problems with determining that and he would like to prepare a bit after all, so he asked you for help. You may assume that if Byteman is tied for the first place, he does not win.
The first line of standard input contains a single integer (), the number of test cases. The following lines contain the descriptions of all test cases.
In the first line of each test case there are three positive integers , and (, ), separated by single spaces and representing the numbers of tasks, contestants and topics respectively. lines follow, each of which describes a contestant. In the line, there are integers from the interval , separated by single spaces, representing the skills of contestant in all topics. The first of those lines describes Byteman.
Write lines to the standard output, one line per each test case. The answer for a single test case is either TAK (meaning YES) or NIE (meaning NO), depending on whether Byteman has a chance of winning the final round.
For the input data:
2 3 6 5 70 100 100 70 100 205 180 70 200 150 180 200 30 25 45 75 45 80 180 180 120 10 120 90 10 15 110 135 150 210 2 2 2 12 12 20 20
the correct result is:
TAK NIE
Explanation of the example: For the first test case, one possible set of tasks that allows Byteman win is: a task from the first topic with difficulty 5, a task from the second topic with difficulty 20 and a task from the third topic with difficulty 75. In such case, the final scores are as follows.
Task author: Jakub Onufry Wojtaszczyk.