import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### h,w = na() r = na() c = na() a = [[0 for j in range(w)]for i in range(h)] for i in range(h-1): for j in range(w-1): a[i+1][j+1] = i+j+1 a[0][0] = 10**9 for i in range(1,h): a[i][0] = w-r[i]+i-1 for i in range(1,w): a[0][i] = h-c[i]+i-1 for i in a: print(*i)