Problem B
Leiðinda rigning
Languages
en
is
Atli is trying to get home, but like most days it’s raining
cats and dogs in Reykjavík. Thus he is trying to plan his route
such that he’ll minimize how wet he gets. More specifically he
has located
Atli isn’t always travelling from the same place and bus
stops aren’t set in stone either. Thus there will be
Atli solved this problem long ago of course, but he won’t tell anyone the solution since that would spoil the fun.
Input
The first line of the input contains two integers
It is guaranteed that it will always be possible to travel from any shelter to any other. Furthermore there will always be at least one working bus stop at any given time.
Output
How wet Atli gets should be printed for every query of type
Sample Input 1 | Sample Output 1 |
---|---|
4 5 1 2 5 1 3 4 2 3 2 2 4 3 3 4 1 9 3 2 1 4 3 2 3 3 1 3 3 3 2 1 2 4 3 1 |
4 2 1 0 4 |