#152Easy
Ilya and queries
Time: 1 s · Memory: 256 MB
- Prefix sums
Statement
You are given a string of characters . and #. For every query find the number of indices such that and .
Input format
The first line contains the string (). The second line contains (). The next lines contain and ().
Output format
For every query print one number on a separate line.
Examples
Input
...... 4 3 4 2 3 1 6 2 6
Output
1 1 5 4
Input
#..### 5 1 3 5 6 1 5 3 6 3 4
Output
1 1 2 2 0
Note
Let if and otherwise. The answer is , that is with prefix sums of . Watch the indices: is not counted.
In the first query of the second example (#..) only works — the answer is .
Source: Codeforces, problem 313B.
