Tom is a string freak. He has got sequences of n words to manipulate. If in a sequence, two same words come together then he’ll destroy each other. He wants to know the number of words left in the sequence after this pairwise destruction.
The first line of input contains an integer denoting the no of test cases. Then T test cases follow. Each test case contains two lines. The first line of input contains an integer n denoting the number of words in a sequence. In the second line are n space separated words of the sequence. Words are contiguous stretches of printable characters delimited by white space.
For each test case in a new line print the number of words left per sequence.
ab aa aa bcd ab
tom jerry jerry tom
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.