fork download
  1. N, M = map(int, input().split())
  2. A = {int(input()) for _ in range(N)}
  3. B = {int(input()) for _ in range(M)}
  4. for S in [A & B, A - B, B - A]:
  5. print(len(S))
  6. print(*sorted(S))
  7.  
  8.  
Success #stdin #stdout 0.02s 28384KB
stdin
6 7
5
10
20
25
45
15
15
45
3
6
9
12
18
stdout
2
15 45
4
5 10 20 25
5
3 6 9 12 18