Coloring Practice (Small)

Count distinct colorings of an n-gon's vertices with up to k colors, identifying colorings under rotations, reflections, and color swaps.

Medium7CombinatoricsBrute forceImplementationNo attempts yetTime limit2sMemory limit256 MB

Problem

You paint the vertices of a regular nn-gon with kk colors. You do not have to use every color.

Two paintings count as one and the same case when a finite number of the following operations turns one into the other.

  • Rotate the polygon.
  • Flip the polygon over.
  • Pick two different colors XX and YY, repaint every vertex of color XX with color YY, and repaint every vertex of color YY with color XX. It is allowed that no vertex has color XX or color YY.

Count how many different paintings there are.

Input

The first line contains nn and kk, separated by a space.

3n63 \le n \le 6, 1k51 \le k \le 5

Output

Print the number of different paintings that satisfy the conditions, modulo 1,000,000,007, on one line.