n,m=map(int,input().split()) ch=list(map(str,input().split())) a=[int(input()) for i in range(n)] if ch[0]=="+": for i in range(n): ans=[] for j in range(1,m+1): ans.append(a[i]+int(ch[j])) print(*ans) else: for i in range(n): ans=[] for j in range(1,m+1): ans.append(a[i]*int(ch[j])) print(*ans)