n, m = map(int, input().split()) op, *B = input().split() A = [input() for _ in range(n)] for i in range(n): print(*[eval(A[i] + op + b) for b in B])