Output #1
350
1400
301
399
There are two shrines and three temples. The shrines are located at distances of $100, 600$ meters from the west end of the road, and the temples are located at distances of $400, 900, 1000$ meters from the west end of the road.
* Query $1$: If we start from a point at a distance of $150$ meters from the west end of the road, the optimal move is first to walk $50$ meters west to visit a shrine, then to walk $300$ meters east to visit a temple.
* Query $2$: If we start from a point at a distance of $2000$ meters from the west end of the road, the optimal move is first to walk $1000$ meters west to visit a temple, then to walk $400$ meters west to visit a shrine. We will pass by another temple on the way, but it is fine.
* Query $3$: If we start from a point at a distance of $899$ meters from the west end of the road, the optimal move is first to walk $1$ meter east to visit a temple, then to walk $300$ meters west to visit a shrine.
* Query $4$: If we start from a point at a distance of $799$ meters from the west end of the road, the optimal move is first to walk $199$ meters west to visit a shrine, then to walk $200$ meters west to visit a temple.