1912 : yifan and string

时间限制:2 Sec 内存限制:128 MiB
提交:12 答案正确:2

提交 状态 讨论区

题目描述

Our brother yifan has some problems about strings, one of them is following.
Given an string S and an integer n, we called the string S is Devil's string, now you need to calculate how many Lucky string which length is n. We regard an string is lucky if it doesn't contain S as substrings

输入

Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing an integer n (1 ≤ n ≤ 10^9).  The next line contains letters that you can use to  create lucky strings. This non-empty line contains lowercase characters only and in ascending order. The third line contains the Devil's string S (1 ≤ length(S) ≤ 50), and S contains characters from the allowed characters only.

输出

For each case, print the case number and the total number of names that don't contain S as substring. As the number can be very large, print the number modulo 2^32.

样例输入

复制
1
5
ab
aaa

样例输出

复制
Case 1: 24

提示


			

来源

FJNU