N,M = map(int,input().split()) l = input().split() op = l[0] del l[0] B = list(map(int,l)) A = [int(input()) for _ in range(N)] for i in range(N): for j in range(M): if op == '+': ans = A[i] + B[j] else: ans = A[i] * B[j] print(ans,end = " ") print()