N, M = map(int, input().split())A = {int(input()) for _ in range(N)}B = {int(input()) for _ in range(M)}for S in [A & B, A - B, B - A]: print(len(S)) print(*sorted(S))
6 7 5 10 20 25 45 15 15 45 3 6 9 12 18
2 15 45 4 5 10 20 25 5 3 6 9 12 18
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!