The railway network of the Byteotian Railways (BR) is a set of two-way tracks. Each track directly connects a pair of stations, at most one track joins any given pair of stations, and between every two stations there is exactly one route that never visits a station twice. In other words, the network is a tree with n stations.
Byteasar is an undercover BR inspector. He chooses one station as his base S and must inspect every other station. His tour works like this:
Riding along any single track takes exactly one hour.
Byteasar will consider every station as a possible base S. For each S, find the smallest possible total travelling time of a valid tour, or report that no valid tour exists for that S.
The first line contains an integer n (1≤n≤1,000,000), the number of stations, numbered from 1 to n. Each of the next n−1 lines contains two integers a and b (1≤a,b≤n, a=b) separated by a single space, describing a track that directly connects stations a and b. Every track is listed exactly once.
Print n lines. Line i must contain a single integer: the minimum total number of hours Byteasar needs to inspect every station when his base is S=i, or −1 if no valid tour exists for S=i.

The figure shows the network from the sample. A full inspection tour exists only for S=2; one optimal order of inspection is 7,4,8,6,1,5,3,9, which takes 23 hours.