Excellent Engineers

No attempts yetTime limit3sMemory limit256 MB

Problem

You work for an agency that places the best software engineers from Belgium, the Netherlands and Luxembourg with companies around the world. The files hold so many strong engineers that the agency asked you to build a tool that picks the most promising candidates quickly.

Every engineer is tested extensively before entering the files. The tests rank all engineers on three skills: communication skills, programming skills, and algorithmic knowledge. The engineer with rank one in algorithmic knowledge is the best algorithmic expert in the files, rank two is the second best, and so on.

The tool has to produce a shortlist of the candidates a customer might want. An engineer goes on the shortlist if no other engineer in the files scores better on all three skills at once. That is, an engineer goes on the list unless some other engineer has better communication skills, better programming skills, and more algorithmic knowledge.

Input

The first line holds one positive integer, the number of test cases, which is at most 100. Each test case is given as follows.

  • One line with a single integer nn (1n1000001 \le n \le 100\,000), the number of engineers in the files.
  • nn lines, each with three space separated integers r1r_1, r2r_2 and r3r_3 (1r1,r2,r3n1 \le r_1, r_2, r_3 \le n): the rank of that engineer in communication skills, programming skills and algorithmic knowledge, in that order.

For each skill and each rank xx between 1 and nn, exactly one engineer has that rank.

Output

For each test case, print one line with a single integer, the number of candidates on the shortlist.