n, m = map(int, input().split()) b = list(input().split()) ope = b[0] b = b[1:] for i in range(n): a = int(input()) for num in b: if ope == "+": print(a + int(num), end = " ") else: print(a * int(num), end = " ") print()