N,M=map(int,input().split()) f_ckinput=input().split() op=f_ckinput[0] B=list(map(int,f_ckinput[1:])) A=[int(input())for i in range(N)] f=lambda x,y:A[x]+B[y] if op=="+" else A[x]*B[y] for i in range(N): print(*[f(i,j)for j in range(M)])