n, m = [int(x) for x in input().split()] w = input().split() op = w.pop(0) h = [input() for _ in range(n)] for hh in h: a = [] for ww in w: a.append(eval(hh + op + ww)) print(*a)