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