import sys input = sys.stdin.readline H,W=map(int,input().split()) R=list(map(int,input().split())) C=list(map(int,input().split())) ANS=[[0]*W for i in range(H)] now=2 for i in range(1,H): for j in range(1,W): ANS[i][j]=now now+=2 ANS[0][0]=10**9 for i in range(1,H): x=R[i] k=ANS[i][W-1-(x-1)] ANS[i][0]=k+1 for j in range(1,W): x=C[j] k=ANS[H-1-(x-1)][j] ANS[0][j]=k+1 for i in range(H): print(*ANS[i])