NICEDAY  The day of the competitors
The International Olympiad in Informatics is coming and the leaders of the Vietnamese Team have to choose the best contestants all over the country. Fortunately, the leaders could choose the members of the team among N very good contestants, numbered from 1 to N (3 ≤ N ≤ 100000). In order to select the best contestants the leaders organized three competitions. Each of the N contestants took part in all three competitions and there were no two contestants with equal results on any of the competitions. We say that contestant А is better than another contestant В when А is ranked before В in all of the competitions. A contestant A is said to be excellent if no other contestant is better than A. The leaders of the Vietnamese Team would like to know the number of excellent contestants.
Input
First line of the input contains an integer t (1 ≤ t ≤ 10 ), equal to the number of testcases. Then descriptions of t testcases follow. First line of description contains the number of competitors N . Each of the next N lines describes one competitor and contains integer numbers ai, bi, ci (1 ≤ ai, bi , ci ≤ N ) separated by spaces, the order of ith competitor's ranking in the first competition , the second competition and the third competition.
Output
For each test case in the input your program should output the number of excellent contestants in one line.
Note: Because the input is too large so we have 4 input files and the total time limit is 4s ( not 1s ).
Example
Input: 1 3 1 2 3 2 3 1 3 1 2 Output: 3
hide comments
rupav:
20191228 08:37:14
Solved using segment tree. Input format is different w.r.t NKTEAM question. 

fardin_abir:
20191102 18:18:34
solved with segment tree in 0.16s, hope will be much easier with BIT. See this blog if can't find out any idea... https://medium.com/amugglespensieve/spojnicedaythedayofthecompetitors33b2918e862e 

harry_shit:
20191020 15:52:33
simple implementation of BIT!! 

sumesh_pandit:
20190415 22:50:13
For those who didn't get the question


yaseenmollik:
20181109 11:17:33
Solved kind of same problem #NKTEAM. But here it gives WA. why?!!


kshubham02:
20170922 06:36:36
Nice problem! If you can't understand, read carefully again.


marzougi :
20170427 12:15:23
Does any one not getting TLE with Java? 

Medo:
20170418 09:49:48
**SPOILERS**


shubham:
20170327 13:26:25
This problem will reduced to counting inversion problem after sorting 

saiful130104:
20170123 17:33:42
if inputs are like this....

Added by:  Nguyen Minh Hieu 
Date:  20060120 
Time limit:  0.109s 
Source limit:  10000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  Base on a problem from BOI 