f=lambda:map(int,input().split()) n,m=f() a=[] *b,=input().split() for y in range(n): a=input() print(*[eval(a+b[0]+c) for c in b[1:]])