import sys def inp(N, f, t): x = sys.stdin.readline() assert x[-1] == '\n' a = x.split() assert all('0' == v or not v.startswith('0') for v in a) *a, = map(int, a) assert len(a) == N assert all(f<=v<=t for v in a) return a def eof(): assert sys.stdin.readline() == '' def solve(R, C): H, W = len(R), len(C) V = [[i*W+j+1 for j in range(W)] for i in range(H)] for i in range(1, H): V[i][0] = V[i][W-R[i]] for i in range(1, W): V[0][i] = V[H-C[i]][i] V[0][0] = 10**9 eof() return V def main(): H, W = inp(2, 1, 500) R = inp(H, 1, W) C = inp(W, 1, H) for x in solve(R, C): print(*x) if __name__ == '__main__': main()