Beautiful number#11115

Beautiful number

1 second
128 megabytes
Easy

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 and (1 \le n, m \le 9) - the sizes of the first and second sets. The second line contains distinct digits d_1, d_2, \ldots, d_n. The third line contains distinct digits r_1, r_2, \ldots, r_m (1 \le d_i, r_i \le 9).

Output

Print the smallest beautiful number.

Examples

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

Example 1

Loading
Loading