n, m = map(int, input().split()) x = input().split() j = 1 for i in range(len(x) - 1): x[j] = int(x[j]) j += 1 y = [int(input()) for i in range(n)] if x[0] == "+": for i in y: ax = "" for j in range(len(x) - 1): ax = ax + str(i + x[j + 1]) + " " print(ax.rstrip()) else: for i in y: ax = "" for j in range(len(x) - 1): ax = ax + str(i * x[j + 1]) + " " print(ax.rstrip())