## Civil War

Time Limit: 2 sec
Memory Limit: 756 MB
Attempts: 18
Accuracy: 22.22%
Author: Akashdeep Goel

As tension between Uchiha clan and rest of the village is increasing , Fourth Hokage of Leaf Village Minato decides to do something to solve this issue.

There are N house in village , some of them belong to Uchihas and rest to others .
As for now Uchihas live spreaded in village between other clans.
Minato thinks of separating both the clans by relocating some of houses and separating them with a straight wall.
For doing this , he may have to reshuffle some Uchiha as well non-Uchihas houses too. He wants as less houses to be disturbed.

You are a famous mathematician in village so he comes you for help . Help him to find minimum no of houses to be relocated to separate the Uchiha Clan .

It is assured that no three house are in straight line and all the houses are situated at integer co-ordinates .

Input :

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.

The first line of each testcase contains a positive integer N- the number of house in village

Next N line contains 3 integers x , y , val with (x,y) denoting the co-ordinate of point and value is the boolean value assigned to point .

Constraints :

T<=10

1<=<=1000

0<,y<=40000

val= {0,1}

Output :

For each test case, print a single integer denoting minimum number of houses need to be relocated.

Sample input :

1

4

4 1 1

5 4 1

3 2 0

6 3 0

Sample Output :

1

ID

SUBMITTED AT

STATUS

LANGUAGE

TIME

MEMORY USED

USER

TIME

STATUS

LANGUAGE

TIME

MEMORY USED