import numpy as np N, M = map(int, input().split()) B = input().split() op = B[0] B = np.array(list(map(int, B[1:]))) if op == '+': for i in range(N): print(*(B + int(input()))) else: for i in range(N): print(*(B * int(input())))