degF = int(input()) F = list(map(int, input().split())) degG = int(input()) G = list(map(int, input().split())) L = degF + degG + 1 ans = [0]*L for i in range(degF+1): for j in range(degG+1): ans[i+j] += F[i]*G[j] % 258280327 for _ in range(L): ans[_] = str(ans[_] % 258280327) print(L-1) print(" ".join(ans))