N,M=map(int,input().split()) L=list(input().split()) B=list(map(int,L[1:])) A=[int(input()) for _ in range(N)] ANS=[[0]*M for _ in range(N)] def f(x,y): if L[0]=="+": return x+y else: return x*y for i in range(N): for j in range(M): ANS[i][j]=f(A[i],B[j]) for ans in ANS: print(*ans)