#C9071. Union of Two Sets

    ID: 53124 Type: Default 1000ms 256MiB

Union of Two Sets

Union of Two Sets

Given two arrays of integers, your task is to compute the union of these two sets. The union, denoted by \(A \cup B\), consists of all distinct elements that appear in either of the two arrays. Output the union in sorted order. For example, if the input arrays are \([1, 2, 3]\) and \([3, 4, 5]\), then the union is \([1, 2, 3, 4, 5]\).

The mathematical definition is given by: \(A \cup B = \{ x : x \in A \text{ or } x \in B \}\).

inputFormat

The input consists of two lines:

  • The first line contains space-separated integers representing the first array (it may be empty).
  • The second line contains space-separated integers representing the second array (it may be empty).

outputFormat

Output a single line containing the sorted union of the two arrays. The integers should be output in increasing order, separated by a single space.

## sample
1 2 3
4 5 6
1 2 3 4 5 6