from itertools import product x,y = map(int,input().split()) N = 10 ans = 0 for v in product((0,1),repeat=N): C = {0:set(),1:set()} for f in product((0,1),repeat=4): a = v[0] for i in range(1,N): b = v[i] a = f[a*2+b] C[a].add(f[2*x+y]) if len(C[0])==len(C[1]): ans = v[:] C1 = C break print(N) print(*ans) t = int(input()) print(C1[t].pop())