B - Xor of Sequences Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200

問題文

狭義単調増加な整数列 A = (A_1, A_2, \dots, A_N), B = (B_1, B_2, \dots, B_M) があります。
A, B のどちらか片方にだけ出現する整数を全て求め、昇順に出力してください。

制約

  • 入力は全て整数
  • 1 \leq N, M \leq 10^3
  • 1 \leq A_1 < A_2 < \dots < A_N \leq 10^3
  • 1 \leq B_1 < B_2 < \dots < B_M \leq 10^3

入力

入力は以下の形式で標準入力から与えられる。

N M
A_1 A_2 \cdots A_N
B_1 B_2 \cdots B_M

出力

A, B のどちらか片方にだけ出現する整数を全て、昇順に空白区切りで出力せよ。


入力例 1

2 2
1 2
1 3

出力例 1

2 3

1AB の両方に含まれます。
2A のみに含まれます。
3B のみに含まれます。
したがって、2, 3 を出力します。


入力例 2

4 4
1 2 3 4
1 2 3 4

出力例 2


空行を出力しても、何も出力しなくても正解になります。

Score : 200 points

Problem Statement

We have two strictly increasing integer sequences A = (A_1, A_2, \dots, A_N) and B = (B_1, B_2, \dots, B_M).
Find all integers that appear in exactly one of A and B and print them in ascending order.

Constraints

  • All values in input are integers.
  • 1 \leq N, M \leq 10^3
  • 1 \leq A_1 < A_2 < \dots < A_N \leq 10^3
  • 1 \leq B_1 < B_2 < \dots < B_M \leq 10^3

Input

Input is given from Standard Input in the following format:

N M
A_1 A_2 \cdots A_N
B_1 B_2 \cdots B_M

Output

Print all integers that appear in exactly one of A and B in ascending order, with space as separator.


Sample Input 1

2 2
1 2
1 3

Sample Output 1

2 3

1 is contained in both A and B;
2 is contained in only A;
3 is contained in only B.
Thus, we should print 2 and 3.


Sample Input 2

4 4
1 2 3 4
1 2 3 4

Sample Output 2


You can print an empty line or nothing.