zeta and The Deathly Hallows

0

0 votes
Hard
Problem

Death is zeta's old friend. Death is helping him in hiding the hocruxes. zeta has already made the hocruxes, he just needs to keep them in the boxes (Each box can contain exaclty one hocrux).

But the hocruxes cannot be packed randomly in any box so Death helps him in packing them. She speaks out load the box number X and the name of the hocrux S such that S can be kept in the box number X.

zeta notes all these box-hocrux pairs and concludes that all the boxes cannot be filled according to the pairs given by Death.

So you need to help zeta in finding the number of maximum boxes which can be filled.

 

Input Format:

First line of input contains a single integer T, denoting the number of test cases.

In each of the next T lines the first line contains an integer N, denoting the number of pairs that Death speaks out loud.

Next N, line contain an inetger X and string S, denoting box number and name of the hocrux respectively such that houcrux S can be packed in the box number X.

 

Output Format:

Print T lines conaining only a single integer denoting the maximum number of boxes that can be filled.

 

INPUT CONSTRAINTS

1T5

1N105

1|S|100

S consists of lower and upper case english alphabets

Time Limit: 1.5
Memory Limit: 256
Source Limit:
Explanation

From box-hocrux pairs, it is clear that there are total 4 boxes.

If Diary is pakced in 1st box then Nagini can be packed in 2nd and Ring in the 3rd.
This gives a total of 3 (total number of filled box).

Editor Image

?