n,m=map(int,input().split()) l=list(input().split()) k=list((input()) for _ in range(n)) enzan=l[0] ll=list(map(str,l[1:])) lst_ans=[] for i in k: lst_temp=[] for j in ll: lst_temp.append(eval(i+enzan+j)) lst_ans.append(lst_temp) for i in lst_ans: print(" ".join(i))