The number of circuits
题号:NC17669
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Niuniu likes traveling. Now he will travel on a special graph.
Given k and n, The directed graph contains n vertices, which are numbered from 0 to n - 1.
For the vertex i, and for 1 <= j <= k, there is a directed edge from vertex i to vertex ((i + j) % n). 

We want to know the number of (directed) cycles, that pass each directed edge exactly once.
As the answer might be very large, you only need to output the answer mod 1000000007.

输入描述:

The first and only line contains two integers, which are k and n.

1 <= k <= 7
2k+1 <= n <= 109

输出描述:

The first and only line contains the answer.
示例1

输入

复制
2 5

输出

复制
11

说明

The answer is not 22.
0 -> 1- > 2 -> 3 -> 4 -> 0 -> 2 -> 4 -> 1 -> 3 -> 0.

0 -> 2 -> 4 -> 1 -> 3 -> 0 -> 1 -> 2 -> 3 -> 4 -> 0.

The two cycles are the same. They all passed the 10 edges.

Only the start edges are different, and we think they are the same.
示例2

输入

复制
3 8

输出

复制
278528

说明

Try a brute force search...