لینکهای مفید برای شرکت در مسابقه:
در طول مسابقه، میتوانید سؤالات خود را از قسمت «سؤال بپرسید» مطرح کنید.
It will be the greatest event of all times, yes… you’ve guessed right… it’s SHAMIR’S BIRTHDAY PARTYYYY!!!
But unfortunately, Shamir is very lonely and he is not in a party mood right now, poor Shamir. So he wants to invite as minimum of his friends as possible (at least one!) as long as no one gets sad. One would get sad if he/she misses someone. Yes as you’ve realized this problem is also love-related. So if Shamir invites a person, he has to invite all of his/her crushes too.
b****** p*** a**
”, Shamir said.You, as a genius programmer (like AmirShams) should help Shamir Figure it out. you will be given the crushes-list of every person that possibly can come to party. You should determine what’s the minimum number of people Shamir should invite so that no one during the party get upset and miss some other bastards. So help Shamir! (Remember, Shamir has to invite someone)
The first line of input shows the number of test cases .
Each test case contains two space separated integers and indicating Shamir’s friends (and their friends too) and number of crushes lists respectively and is followed by lines.
Each of following lines there will be two integers and indicating has a crush over .
Shamir friends are weird like him. don’t care about his friends genders. so Triangle-love is possible!
For each test case, print the minimum number of Shamir’s friends that should come to the party so that anyone will have a good time in the party (and possibly outside the party).