Modern Machine
문제
Bitaro is given JOI machine as a birthday present. JOI machine consists of one ball, light tiles, and buttons. The light tiles are numbered from to . When Bitaro turns the power on, Light tile (1 ≤ i ≤ N) emit light of color (blue (B) or red (R)). The buttons are numbered from to . If Bitaro pushes Button (1 ≤ j ≤ M), the following happen.
- The ball is placed on Light tile .
- Light tile becomes red (regardless of its original color).
- The following operations are performed until the ball is removed.
- Let be the index of the light tile where the ball is currently placed.
- If Light tile is blue,
- Light tile becomes red. After that, if , the ball is removed. Otherwise, the ball moves to Light tile .
- If Light tile is red,
- Light tile becomes blue. After that, if , the ball is removed. Otherwise, the ball moves to Light tile .
Bitaro is interested in JOI machine. He plans to perform experiments. In the -th experiment (1 ≤ k ≤ Q), after Bitaro turns the power on, Bitaro pushes Buttons in this order. After Bitaro pushes a button, he will not push the next button and wait until the ball is removed.
Given information of JOI machine and the experiments, write a program which calculates, for each experiment, the number of light tiles whose colors are red when the experiment finishes.
입력
Read the following data from the standard input.
출력
Write lines to the standard output. In the -th line (1 ≤ k ≤ Q), the output should contain the number of light tiles whose colors are red when the -th experiment finishes.
예제
예제 1
5 1 RBRRB 4 1 1 1
1
예제 2
5 3 RBRBR 1 3 4 2 2 3 1 3
5 0
예제 3
10 3 BBRRBRBRRB 2 10 5 1 1 3
2
예제 4
10 10 RRRRRRRRRR 3 1 4 1 5 9 2 6 5 3 5 1 7 2 8 3 9 4 10 1 10
4 8 10 0 9
예제 5
10 10 RRRBBBBBBB 3 1 4 1 5 9 2 6 5 3 5 1 10 2 9 3 8 4 7 5 6
2 6 0 10 7
예제 6
30 10 RRRBBRBBBRBBBRBRBRRRRRBBBBRBRR 3 28 2 29 1 30 6 14 7 7 10 1 10 2 3 2 5 2 8 3 3 3 6 4 5 4 7 5 9 10 10
21 15 15 4 17 16 14 20 12 23