Competitions

# Beautiful number

You are given two sets of non-zero digits.

In decimal notation, we call a positive integer beautiful if it contains at least one digit from each of these sets.

Find the smallest beautiful number.

#### Input

The first line contains two integers n and m (1n, m9) - the sizes of the first and second sets. The second line contains n distinct digits d1, d2, ..., dn. The third line contains m distinct digits r1, r2, ..., rm (1di, ri9).

#### Output

Print the smallest beautiful number.

#### Example

In the example, there are such beautiful numbers as 13, 18, 3451 and so on. The smallest of them is 13.

Time limit 1 second
Memory limit 128 MiB
Input example #1
2 2
1 4
8 3

Output example #1
13

Source 2022 Azerbaijan Republic Olympiad, Semifinals, High League, March 8