logo AlgoBeat OnlineJudge
登录 注册

#209285. [EC Final 2022] Binary String

内存限制:1024 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given a binary string arranged on a cycle. Each second, you will change every to simultaneously. In other words, if and , you swap and . For example, we will change to .

You need to answer how many different strings will occur in infinite seconds, modulo .

Note: Two strings and are different if there exists an integer such that . Thus, the cyclic shifts of a string may be different from the original string.

输入格式

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

For each test case, the first line contains a binary string .

It is guaranteed that the sum of lengths of strings over all test cases does not exceed .

输出格式

For each test case, output one integer representing the answer in one line.

样例

样例输入 1

3
1
001001
0001111

样例输出 1

1
3
9