N, M = map(int,input().split()) B = input().split() ans = [] if B[0] == "+": for k in range(N): temp = [] A = int(input()) for l in range(1,M+1): temp.append(A+int(B[l])) ans.append(temp) else: for k in range(N): temp = [] A = int(input()) for l in range(1,M+1): temp.append(A*int(B[l])) ans.append(temp) for e in ans: print(*e)