#P10614. BZOJ3864 Hero meet devil
BZOJ3864 Hero meet devil
Problem Description
You are given a string over the alphabet ACGT. Define as the longest common subsequence of two strings and .
For each , find how many strings of length over the alphabet ACGT satisfy . Output the answer modulo .
Input Format
The first line contains an integer , the number of test cases.
For each test case, the first line contains a string , and the second line contains an integer .
Output Format
For each test case, output the answers for , one per line.
1
GTC
10
1
22783
528340
497452
Hint
For of the testdata, it is guaranteed that , , .
Translated by ChatGPT 5