Never Say Never

No attempts yetTime limit2sMemory limit128 MB

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, NN employees have worked at the company over its history. Employee ii is described by four integers sis_i, eie_i, aia_i, bib_i: the employee was hired at time sis_i, left the company (or the company let them go) at time eie_i, and at any moment tt their effectiveness equals ait+bia_i \cdot t + b_i.

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.

  • aia_i may be negative.
  • Effectiveness may be negative (the employee is harming the company instead of generating profit).
  • Every employment interval [si,ei][s_i, e_i] is closed at both ends, and you must consider every real-valued moment tt, not only integer ones.

Input

The first line contains an integer ZZ (1Z101 \le Z \le 10), the number of test sets. The test sets follow.

The first line of each test set contains an integer NN (1N1051 \le N \le 10^5), the number of employees in the company's history. Each of the next NN lines contains four space-separated integers sis_i, eie_i, aia_i, bib_i, where 0si,ei1060 \le s_i, e_i \le 10^6 and 106ai,bi106-10^6 \le a_i, b_i \le 10^6.

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.