n,m=map(int,input().split()) tmp=map(str,input().split()) op=tmp[0] arr1=[int(tmp[i]) for i in range(1,m+1)] arr2=[int(input()) for i in range(n)] c=[[0]*m for _ in range(n)] for i in range(n): for j in range(m): if op=='+': c[i][j]=arr2[j]+arr1[i] else: c[i][j]=arr1[j]*arr2[i] for i in range(n): print(*c[i])