import numpy as np 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 F = np.array(F) G = np.array(G) for i in range(degF+1): for j in range(degG+1): ans[i+j] += (F[i]% 258280327)*(G[j] % 258280327) for _ in range(L): ans[_] = str(ans[_] % 258280327) if (degF == 0 and F[0] == 0) or (degG ==0 and G[0] == 0): print(0) print(0) else: print(L-1) print(" ".join(ans))