In a country there are cities numbered from to . To Travel along the cities there are total N bi directional roads. For each city numbered () there is a bi-directional road between city i and city . Furthermore, there is a road between city and city . People can only use any of these roads to travel from a city to another. As travel technology of this country is very advanced, it requires only 1 second time to travel from city to city if there is a road between these two cities. Now initially you will be given the address of people. That is, for every people you will be given an integer , the city where person lives. Then There will be queries. In each query you will be given an integer . You will have to tell the total time that is required for all people to travel from their city to city . Now as we know everyone hates long time travelling, they will take the shortest path to travel from their cities to city .
On the first line, there will be two integers () and () described in statement. Then the next line will contain one number each, of them will be (), the number of the city where person lives. Then there will be an integer (), the number of queries. Then the following lines will contain one integer () each, the number (ID) of destination city described in statement.
For each query print an integer, the total time that is required for all people to travel from their city to city .
Input | Output |
---|---|
10 2 2 9 2 10 5 | 3 7 |