Given n and k, calculate the expected number of vertices in the suffix automaton of a random string of length n over alphabet of size k. If r is the answer, output r⋅kn modulo 109+7.
The first line contains the number of tests T. Each of the next T lines contains integers n and k (1≤k≤n≤40). All tests in the input are different.
Output T lines with answers for tests.
Let S(s) be the set of all substrings of s. Suffix automaton of a string s is the smallest directed acyclic graph with a specified vertex v_0 and an assignment l(e) of characters to all edges of G that satisfies the following property: S(s)=l(e_1)…l(e_k)∣(e_1,…,e_k) — a path starting at v_0.