H,W=map(int,input().split()) R=list(map(int,input().split())) C=list(map(int,input().split())) ans=[[i+j for i in range(W)] for j in range(H)] ans[0][0]=pow(10,9) for i in range(1,H): ans[i][0]=ans[i][-1]+1-R[i] for i in range(1,W): ans[0][i]=ans[-1][i]+1-C[i] for i in range(H): print(*ans[i])