Beautiful number
Easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
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 - the sizes of the first and second sets. The second line contains distinct digits . The third line contains distinct digits .
Output
Print the smallest beautiful number.
Examples
In the example, there are such beautiful numbers as , , and so on. The smallest of them is .
Input #1
Answer #1
Submissions 2K
Acceptance rate 23%