D. Period
time limit per test
1 s
memory limit per test
256 megabytes
input
standard input
output
standard output

Zayin have learned how to compute the number of periods of a string recently.

As his girlfriend, Ziyin would like to give Zayin some strings and test whether he really learn the knowledge well. But Ziyin is too lazy to produce strings which are completely different, so she would firstly give Zayin a string, and ask him if she modify the $$$i$$$-th character of the string to #, what is the number of periods of the new string. (Note that Ziyin wouldn't really perform the modification)

It's really a big question for Zayin. Can you help him so that he would not lose face in front of his girlfriend?

Input

The first line contains a string $$$s$$$ ($$$1\le|s|\le 10^6$$$), which only contains lowercase letters.

The second line contains an integer $$$q$$$ ($$$1\le q\le 10^6$$$), indicating the number of queries.

Each of the next $$$q$$$ lines contains an integer $$$i\ (1\le i\le |s|)$$$, indicating Ziyin would modify the $$$i$$$-th character of the string to #.

Output

For each of the $$$q$$$ queries, print an integer indicating the number of periods of the new string after Ziyin's modification.

Example
Input
ccpc
4
1
2
3
4
Output
0
1
1
0
Note

A integer number $$$T$$$ is a period of a string $$$s$$$ if and only if $$$1\le T \lt |s|$$$ and $$$s[i]=s[i-T]$$$ for every $$$i\in\big(T,|s|\big]$$$.