SP27487 POLICEMEN - Police Men
Description
There is a country of _n_ cities and _n-1_ bidirectional roads you can go from any city to another using its roads
You are a police man and there is a theif who is going to escape from the country using an airport in city 1 you are given _m_ queries which of type "_a b"_ which means the thief is in city _a_ and you are in city _b_ you should find if it's possible to catch him before he escape or not and find the city which you will catch him in if it's possible.
You are moving at the same speed the thief moving at and the thief is taking the shortest path to city 1
If you arrived in a city in the same time as the thief you can catch him in it if you arrived before him you can wait for him
If there is more than one city you can catch him in print the nearest one to you.
Input Format
the first line contains an integer _n_ (_1 _n _10 $ ^{4} $_ ) then _n-1_ lines each contains two integers which means there is a road between city _u_ and _v___
then an intger _q_ (_1 10 $ ^{4} $_ ) and _q_ lines of form a b (__1 a , b _n_) which are the thief's position and your position__
Output Format
for each query print YES then a space then the city which you will catch him in if it's possible otherwise print NO