Competitions

# 26-ЖДУ_2

# 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** (**1** ≤ **n**, **m** ≤ **9**) - the sizes of the first and second sets. The second line contains **n** distinct digits `d`

, _{1}`d`

, ..., _{2}`d`

. The third line contains _{n}**m** distinct digits `r`

, _{1}`r`

, ..., _{2}`r`

(_{m}**1** ≤ `d`

, _{i}`r`

≤ _{i}**9**).

#### 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**.

Input example #1

2 2 1 4 8 3

Output example #1

13