Bitaro is given JOI machine as a birthday present. JOI machine consists of one ball, N light tiles, and M buttons. The light tiles are numbered from 1 to N. When Bitaro turns the power on, Light tile i (1≤i≤N) emit light of color C_i (blue (B) or red (R)). The buttons are numbered from 1 to M. If Bitaro pushes Button j (1≤j≤M), the following happen.
The ball is placed on Light tile A_j.
Light tile A_j becomes red (regardless of its original color).
The following operations are performed until the ball is removed.
Bitaro is interested in JOI machine. He plans to perform Q experiments. In the k-th experiment (1≤k≤Q), after Bitaro turns the power on, Bitaro pushes Buttons L_k,L_k+1,…,R_k 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.
N M
C_1C_2⋯C_N
A_1 A_2 ⋯ A_M
Q
L_1 R_1
L_2 R_2
⋮
L_Q R_Q
Write Q lines to the standard output. In the k-th line (1≤k≤Q), the output should contain the number of light tiles whose colors are red when the k-th experiment finishes.
B or R.