A Time-Turner is a magical device used to travel back in time, spend some time there, and then get back to the current time.
Rose Granger has found a Time-Turner in the libraries of Hogwarts and took it upon herself to go back in time and take out some members of the Black family, in order to save the lives of muggles (humans without any magical ability).
The Black family has members, numbered to in order of being born. Member is the first member of the Black family with a recorded history. For each (), member i is a direct descendant of member ( < ). i.e., member and all of his/her ancestors are an ancestor of member . It is also written in the books that the member of the Black family is responsible for the death of muggles.
Now Rose has q options. The option is to use the Time-Turner to go back in time and take out all the members from to () and then come back to the current time. As a consequence of this action, any member of the Black family who has an ancestor among members to will never be born. For any member i who is among members to (i.e. ), or has an ancestor among members to , Rose will save lives.
For each option, help Rose to find out how many lives she will save if she takes that option.
The first line of the input contains two integers and (, ). The second line contains space-separated integers to (). The third line contains integers to (). Each of the next q lines contains one option; The line contains two integers and ().
For each (), output the number of lives Rose will save if she takes the option.