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.
The first line holds one positive integer, the number of test cases, which is at most 100. Each test case is given as follows.
For each skill and each rank x between 1 and n, exactly one engineer has that rank.
For each test case, print one line with a single integer, the number of candidates on the shortlist.