n, m = map(int, input().split()) op, *b = input().split() a = [input() for _ in range(n)] for ea in a: row = [] for eb in b: eq = ea + op + eb num = eval(eq) row.append(num) print(*row)