baba-and-unix

Tech Families are an integral part of life @ VNIT. Dewang has quiet a few tech sons and daughters. His tech family is such that every person in his family can be represented by N relations.
A regular relation looks like this - /son1/son2/son3
/ operator is used here as the son of/daughter of operator.
The first / operator implies that the ultimate parent is Dewang. And so there is no need to mention his name in the relation. But Dewang is not satisfied with his small family. So now Dewang with his sons and daughters plan to increase their family tree. So they take interviews from first years for those who are worthy. After the interview they think of M relations that they want to implement. After such a long meeting Dewang is exhausted but he needs to find out how many adoptions are to be made so that all of the adoption relations are satisfied. Help Dewang count the number of adoptions.

NOTE: Adoption schemes are such that there might be some first year who will be adopting first years.

INPUT 

First line of the Input file has an integer T which is the number of test cases. First line of each test case contains 2 integers N and M. Next N line contains all the relations that already exist in his tech family. Next M line contains M relations that are to be made.

OUTPUT 

For every test case output a single integer which gives the value of adoptions that are to be made.

LIMITS

Every name in the relation follows the regular expression :[a-z0-9]

SAMPLE INPUT
2
0 2
/neha/shreya/anushree
/neha/shreya/shubham
2 1
/yogeshree
/yogeshree/radhika
/yogeshree

SAMPLE OUTPUT
4
0

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions: