def main(): H, W = map(int, input().split()) *R, = map(int, input().split()) *C, = map(int, input().split()) 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] = V[-1][-1] for x in V: print(*x) if __name__ == '__main__': main()