| Kotlin Heroes: Episode 13 |
|---|
| Finished |
Alice and Bob are planning to play an online game together but haven't decided on which one yet. Alice has a list of $$$n$$$ games she enjoys: $$$a_1, a_2, \dots, a_n$$$. Bob, on the other hand, has a list of $$$m$$$ games he likes: $$$b_1, b_2, \dots, b_m$$$. They share at least one game in common between their lists.
To choose a game, they take turns suggesting games from their lists. Alice begins by suggesting one of her favorite games. If Bob likes it, they play that game. If not, Bob suggests one of his favorite games. If Alice likes it, they play that game. This alternating process continues, with Alice and Bob each suggesting games from their lists in turn, ensuring that no game is suggested more than once.
Your task is to calculate the maximum possible number of suggestions they will make while choosing which game to play.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases.
The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$).
The second line contains $$$n$$$ integers $$$a_1 \lt a_2 \lt \cdots \lt a_n$$$ ($$$1 \le a_i \le 100$$$).
The third line contains $$$m$$$ integers $$$b_1 \lt b_2 \lt \cdots \lt b_m$$$ ($$$1 \le b_i \le 100$$$).
Arrays $$$a$$$ and $$$b$$$ contain at least one common integer.
For each test case, print a single integer — the maximum possible number of suggestions they will make while choosing which game to play.
32 31 22 3 51 1554 21 3 4 74 6
3 1 4
In the first test case, the maximum number of suggestions is $$$3$$$. It is achieved as follows:
In the second test case, Alice can only suggest game $$$5$$$, which Bob likes, so they will immediately go to play it.
In the third test case, the maximum number of suggestions is $$$4$$$. It is achieved as follows:
| Name |
|---|


