Hero meet devil

时间限制:8s      空间限制:128MB

题目描述

There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is just like a boy in love and can’t refuse any request from the devil. Also, this devil is looking like a very cute Loli.
After the ring has been destroyed, the devil doesn't feel angry, and she is attracted by z*p's wisdom and handsomeness. So she wants to find z*p out.
But what she only knows is one part of z*p's DNA sequence S leaving on the broken ring.
Let us denote one man's DNA sequence as a string consist of letters from ACGT. The similarity of two string S and T is the maximum common subsequence of them, denote by LCS(S,T).
After some days, the devil finds that. The kingdom's people's DNA sequence is pairwise different, and each is of length m. And there are 4^m people in the kingdom.
Then the devil wants to know, for each 0 <= i <= |S|, how many people in this kingdom having DNA sequence T such that LCS(S,T) = i.
You only to tell her the result modulo 10^9+7.


输入格式

The first line contains an integer T, denoting the number of the test cases.
For each test case, the first line contains a string S. the second line contains an integer m.
T<=5
|S|<=15. m<= 1000.


输出格式

For each case, output the results for i=0,1,...,|S|, each on a single line.


样例输入

1
GTC
10

样例输出

1
22783
528340
497452

提示

没有写明提示


题目来源

By WJMZBMR

Menuappsclose