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