#C3306. Intersection of Two Lists

    ID: 46719 Type: Default 1000ms 256MiB

Intersection of Two Lists

Intersection of Two Lists

You are given two lists of unique integers. Your task is to find the intersection of these two lists, and output a sorted list of the common elements. The output should be printed as a single line with integers separated by a single space. If there is no common element, print an empty line.

Mathematically, if we denote the two lists as \(A\) and \(B\), you need to compute the intersection \(A \cap B\) and output the sorted result.

inputFormat

The first line contains two space-separated integers \(n\) and \(m\), representing the number of elements in the first and second list respectively. The second line contains \(n\) space-separated integers representing the first list. The third line contains \(m\) space-separated integers representing the second list.

outputFormat

Print the sorted list of common elements separated by a single space. If there are no common elements, print an empty line.

## sample
6 6
1 3 4 6 7 9
1 2 4 5 9 10
1 4 9