h,w=map(int,input().split()) op,*w=input().split() h=[input() for i in range(h)] for i in h: for j in w: print(eval(i+op+j),end=' ') print()