N, M = list(map(int, input().split())) S = list(input().split()) AN = [input() for _ in range(N)] op = S[0] S = S[1:] for a in AN: res = [eval("".join([a, op, s])) for s in S] print(*res)