#acl1a. [acl1_a]Reachable Towns
[acl1_a]Reachable Towns
Problem Statement
There are cities on a 2D plane. The coordinate of the -th city is . Here and are both permuations of .
For each , find the answer to the following question:
Rng is in City . Rng can perform the following move arbitrarily many times:
- move to another city that has a smaller -coordinate and a smaller -coordinate, or a larger -coordinate and a larger -coordinate, than the city he is currently in.
How many cities (including City ) are reachable from City ?
Constraints
- is a permutation of .
- is a permutation of .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. In -th line print the answer to the question when .
Sample Input 1
Sample Output 1
Rng can reach City from City , or conversely City from City .