


Two cards are said to be of different types if they have different numbers written on them.
The first line of input contains an integer ‘T’ denoting the number of test cases.
Then the T test cases follow.
The first line of each test case contains two space-separated integers ‘N’ and ‘M’ denoting the total number of cards in the first and the second pack, respectively.
The second line of each test case contains ‘N’ space-separated, non-decreasing integers representing the numbers written on the cards of the first pack.
The third line of each test case contains ‘M’ space-separated, non-decreasing integers representing the numbers written on the cards of the second pack.
For each test case, the number of different types of cards (including both the packs) and the number of similar cards in both packs is printed.
Both the numbers should be separated by a single space.
The output of each test case is printed in a separate line.
1 <= T <= 10
1 <= N, M <= 500
-10^9 <= arr[i] <= 10^9
Time Limit: 1 sec
For different cards, iterate one by one through both the packs and pick only those types of cards that aren’t picked yet.
For similar cards, iterate through pack 1 and also iterate through the pack 2 as a nested loop inside the previous loop. If found any card same in both the packs and isn’t picked yet, then pick it.
Algorithm:
For different cards: Set two pointers on both of the packs (one on each). Initially, point both the pointers to the first card of their respective packs.
Now, iterate through both the packs simultaneously and after each iteration increment the counter by 1. Whenever you find the same cards in both the packs, increment both the pointers by 1. If cards are different, only increment (by 1) the pointer for which card value is smaller. After this increment both the pointers individually till you find the different types of card in both the pack respectively.
For similar cards: Again, set pointers on both of the packs. Initially, point both the pointers to the first card of their respective packs. This time, increment the counter whenever similar cards are found and then update the pointers according to the card value (Number written on the card).
Algorithm: