N,M=list(map(int,input().split())) l1=input().split() l2=[int(input()) for i in range(N)] op=l1[0] l1=l1[1:] l1=[int(n) for n in l1] for i in range(N): for j in range(M): print(eval(str(l2[i])+op+str(l1[j])),end="") if j!=M-1: print(' ',end="") if i!=N-1: print('\n',end="")