#C6531. Symmetric Difference

    ID: 50302 Type: Default 1000ms 256MiB

Symmetric Difference

Symmetric Difference

Given two lists of integers, your task is to compute the symmetric difference between them. The symmetric difference includes all elements that are in exactly one of the two lists. Duplicate values should be considered only once. The result must be sorted in ascending order.

Mathematically, the symmetric difference for two sets \(A\) and \(B\) is defined as:

$$ A \triangle B = (A \setminus B) \cup (B \setminus A) $$

Use input from stdin and output the result on stdout as a single line. If the resulting set is empty, output an empty line.

inputFormat

The input consists of four lines:

  • The first line contains an integer \(n\) representing the number of elements in the first list.
  • The second line contains \(n\) space-separated integers representing the first list.
  • The third line contains an integer \(m\) representing the number of elements in the second list.
  • The fourth line contains \(m\) space-separated integers representing the second list.

outputFormat

Output a single line containing the sorted symmetric difference of the two lists. The numbers should be separated by a single space. If there are no numbers to output, print an empty line.

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