#C8943. Toy Train Route
Toy Train Route
Toy Train Route
You are given a train route with n stations arranged in a single line in order. Each station has a unique name. Given a list of q queries, each query provides a starting station and a destination station (with the guarantee that the starting station appears before or is the same as the destination station on the train route). Your task is to compute, for each query, the number of stations between the starting and destination stations inclusive.
Note: The stations are provided in the order they appear in the train route, and the queries are given accordingly.
Input/Output: The input is read from standard input and the output is printed to standard output.
inputFormat
The input begins with a line containing an integer n (the number of stations). The second line contains n station names separated by spaces. The third line contains an integer q (the number of queries). Each of the next q lines contains two station names separated by a space representing the starting station and the destination station.
outputFormat
Output a single line containing q integers. Each integer is the number of stations encountered on the train route from the starting station to the destination station (inclusive). The results should be printed in the same order as the queries, separated by a space.
## sample5
central park union station harbor
2
park station
central harbor
3 5
</p>