MOD = 258280327

def main():
    import sys
    input = sys.stdin.read().split()
    ptr = 0
    
    n = int(input[ptr])
    ptr += 1
    f_coeffs = list(map(int, input[ptr:ptr + n + 1]))
    ptr += n + 1
    
    m = int(input[ptr])
    ptr += 1
    g_coeffs = list(map(int, input[ptr:ptr + m + 1]))
    ptr += m + 1
    
    # Mod each coefficient
    f = [x % MOD for x in f_coeffs]
    g = [x % MOD for x in g_coeffs]
    
    # Compute the product
    product_degree = n + m
    product = [0] * (product_degree + 1)
    
    for i in range(len(f)):
        a = f[i]
        if a == 0:
            continue
        for j in range(len(g)):
            product[i + j] = (product[i + j] + a * g[j]) % MOD
    
    # Trim trailing zeros to find the actual degree
    degree = product_degree
    while degree > 0 and product[degree] == 0:
        degree -= 1
    
    print(degree)
    print(' '.join(map(str, product[:degree + 1])))

if __name__ == "__main__":
    main()