Never Say Never
Time limit2sMemory limit128 MB
Decide whether two employees employed at the same moment ever have equal linear effectiveness values.
Problem
"How on earth am I supposed to set my employees' salaries?" wondered director Karierowitch. "I want everyone paid in proportion to their effectiveness. But effectiveness keeps changing, and surely I will never have two employees with exactly the same effectiveness at the same time."
Many years have passed since then. In total, employees have worked at the company over its history. Employee is described by four integers , , , : the employee was hired at time , left the company (or the company let them go) at time , and at any moment their effectiveness equals .
Determine whether there was ever a moment in the company's history at which two employees who were both employed at that moment had exactly the same effectiveness.
- may be negative.
- Effectiveness may be negative (the employee is harming the company instead of generating profit).
- Every employment interval is closed at both ends, and you must consider every real-valued moment , not only integer ones.
Input
The first line contains an integer (), the number of test sets. The test sets follow.
The first line of each test set contains an integer (), the number of employees in the company's history. Each of the next lines contains four space-separated integers , , , , where and .
Output
For each test set, print on its own line "TAK" if there exists a moment at which some pair of simultaneously employed employees had the same effectiveness, and "NIE" otherwise.