Unique pairs of numbers in collections
Task «Unique pairs of numbers in collections»
Input Format
The first line contains two integers N and M (1 ≤ N, M ≤ 1000) — the sizes of the first and second lists. The second line contains N integers — the elements of the first list. The third line contains M integers — the elements of the second list. All numbers do not exceed 10^6 in absolute value.
Output Format
In the first line, output a single number K — the number of unique pairs. In the next K lines, output the pairs themselves in the format "a b", each on a new line, in ascending order of a, and for equal a, in ascending order of b.