Beppa and SwerChat

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Beppa and her circle of geek friends keep up to date on a group chat in the instant messaging app SwerChatTM.

The group has nn members, excluding Beppa. Each of those members has a unique ID between 11 and nn. When a user opens a group chat, SwerChatTM displays the list of other members of that group, sorted by decreasing times of last seen online (so the member who opened the chat most recently is the first of the list). However, the times of last seen are not displayed.

Today, Beppa has been busy all day: she has only opened the group chat twice, once at 9:00 and once at 22:00. Both times, she wrote down the list of members in the order they appeared at that time. Now she wonders: what is the minimum number of other members that must have been online at least once between 9:00 and 22:00?

Beppa is sure that no two members are ever online at the same time and no members are online when Beppa opens the group chat at 9:00 and 22:00.

입력

Each test contains multiple test cases. The first line contains an integer tt (1t10,0001 ≤ t ≤ 10\\,000) — the number of test cases. The descriptions of the tt test cases follow.

The first line of each test case contains an integer nn (1n1051 ≤ n ≤ 10^5) — the number of members of the group excluding Beppa.

The second line contains nn integers a_1,a_2,,a_na\_1, a\_2, \dots , a\_n (1a_in1 ≤ a\_i ≤ n) — the list of IDs of the members, sorted by decreasing times of last seen online at 9:00.

The third line contains nn integers b_1,b_2,,b_nb\_1, b\_2, \dots , b\_n (1b_in1 ≤ b\_i ≤ n) — the list of IDs of the members, sorted by decreasing times of last seen online at 22:00.

For all 1i<jn1 ≤ i < j ≤ n, it is guaranteed that a_ia_ja\_i \ne a\_j and b_ib_jb\_i \ne b\_j.

It is also guaranteed that the sum of the values of nn over all test cases does not exceed 10510^5.

출력

For each test case, print the minimum number of members that must have been online between 9:00 and 22:00.

힌트

In the first test case, members 44, 55 must have been online between 9:00 and 22:00.

In the second test case, it is possible that nobody has been online between 9:00 and 22:00.