import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N,M=MI() Bo=input().split() B=list(map(int, Bo[1:])) A=[0]*N for i in range(N): A[i]=I() ans=[[0]*M for _ in range(N)] for i in range(N): for j in range(M): if Bo[0]=="+": ans[i][j]=A[i]+B[j] else: ans[i][j]=A[i]*B[j] for i in range(N): print(' '.join(map(str, ans[i]))) main()