import numpy as np N = int(input()) F = list(map(int, input().split())) p1 = np.poly1d(F[::-1]) M = int(input()) G = list(map(int, input().split())) p2 = np.poly1d(G[::-1]) mod = 258280327 r = p1*p2 print(r.order) coef = r.c ans = [] for num in coef[::-1]: ans.append(num%mod) print(*ans)