Set Union

#4N_RedWings1
Limits 1s, 512 MB

Given two sets of integers, print the set containing the union of the two input sets.

For example, given the sets:

  • {1, 3, 5, 7, 8}
  • {2, 3, 4, 7, 9}

The union of the two sets is:

  • {1, 2, 3, 4, 5, 7, 8, 9}

You can learn more about set union here.

Input

The first line of the input will contain two integers N and M (0 < N, M < 100).

The following line will contain N integers, the members of the first set.

The line after that will contain M integers, the members of the second set.

The members of both sets will be given in increasing order.

Output

Print the members of the union set in the same line, separated by space sorted in increasing order.

Sample

InputOutput
5 5
1 3 5 7 8
2 3 4 7 9
1 2 3 4 5 7 8 9

Submit

Login to submit.

Contributors

riyad000

Statistics

85% Solution Ratio
kimiyukiEarliest, Feb '19
YouKnowWhoFastest, 0.0s
rased_299Lightest, 0 B
saitotaShortest, 26B
Toph uses cookies. By continuing you agree to our Cookie Policy.