You build a graph on N vertices. Number the vertices 1 through N and paint each one with one of K colors. Any coloring is allowed.
Once the colors are fixed, you add edges. The edges must follow two rules.
- If 1≤j<i≤N and vertex i and vertex j have different colors, you may add an edge from i to j. You may also leave it out.
- Every vertex i with 2≤i≤N has at most one outgoing edge, so the out-degree of vertex i is never more than 1.
Vertex 1 has no vertex with a smaller number, so it can never have an outgoing edge.
Two graphs are the same when every vertex carries the same color in both and the two edge sets are equal. For example, with N=3 and K=2 there are 24 different graphs, shown below.

Given N and K, find the number of different graphs modulo 1,000,000,007.