8473: String

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

There is a string of length n, S[l..r]  represents the string concatenated from the lth character to the rth character, and  Slen is the length of the string S[1..Slen]  represents the whole S string).
We define FG as the number of positive integers x that satisfy the following conditions:
  1. 1≤x≤Glen
  2. G[1,x]=G[Glen−x+1,Glen]
  3. The length of the common part of the intervals [1,x] and ][Glen−x+1,Glen] is greater than 0 and is divisible by k.
Now ask for the value of  ∏i=1n(FS[1..i]+1) modulo 998244353.


Sample Input
1 abababac 2
Sample Output
24
Hint
Note that the stack space of the judge system is a bit small, please pay attention to the reasonable allocation of memory.

输入格式

Input
The first line of input is a positive integer T(T10) representing the number of data cases.
For each cases:
first line input a string S of lowercase letters, no longer than 106.
second line input a positive integer k(1kSlen).

输出格式

Output
For each cases, output a line with a positive integer representing the answer.

输入样例 复制

1
abababac
2

输出样例 复制

24

分类标签