import numpy as np n, m = map(int, input().split()) operand, *columns = input().split() columns = np.array(columns, dtype = int) rows = [] for _ in range(n): rows.append(int(input())) rows = np.array(rows, dtype=int) if operand == '+': matrix = rows.reshape(-1, 1)+columns elif operand == '*': matrix = rows.reshape(-1, 1)*columns for row in matrix: for element in row: print(element, end=" ") print()