#z1023. mex(mex)

mex(mex)

Description

image

Format

Input

第一行包含一个正整数 n ,表示 p, q 的长度。

接下来两行,第一行为 p,第二行为 q。

Output

输出一行一个整数表示答案。

Samples

3 
1 3 2 
2 1 3
2
7
7 3 6 2 1 5 4
6 7 2 5 3 1 4
16
6
1 2 3 4 5 6
6 5 4 3 2 1
11

大样例:mex4.in mex4.ans

Limitation

image

1s, 512MiB for each test case.