n,m=map(int,input().split()) c=list(map(str,input().split())) a=[0]*(n) for i in range(n): a[i]=int(input()) op=c[0] b=[0]*m for i in range(m): b[i]=int(c[i+1]) if op=='+': for i in range(n): d=[] for j in range(m): d.append(a[i]+b[j]) print(' '.join(d)) else: for i in range(n): d=[] for j in range(m): d.append(a[i]*b[j]) print(' '.join(d))