#P10614. BZOJ3864 Hero meet devil

BZOJ3864 Hero meet devil

Problem Description

You are given a string SS over the alphabet ACGT. Define LCS(S,T)\text{LCS}(S,T) as the longest common subsequence of two strings SS and TT.

For each 0iS0 \leq i \leq |S|, find how many strings TT of length mm over the alphabet ACGT satisfy LCS(S,T)=i|\text{LCS}(S,T)| = i. Output the answer modulo 109+710^9+7.

Input Format

The first line contains an integer TT, the number of test cases.

For each test case, the first line contains a string SS, and the second line contains an integer mm.

Output Format

For each test case, output the answers for i=0,1,,Si = 0,1,\dots,|S|, one per line.

1
GTC
10
1
22783
528340
497452

Hint

For 100%100\% of the testdata, it is guaranteed that 1T51 \leq T \leq 5, 1S151 \leq |S| \leq 15, 1m10001 \leq m \leq 1000.

Translated by ChatGPT 5