Inspection

No attempts yetTime limit5sMemory limit128 MB

Problem

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 nn stations.

Byteasar is an undercover BR inspector. He chooses one station as his base SS and must inspect every other station. His tour works like this:

  • He starts at station SS.
  • He repeatedly picks a station he has not inspected yet, rides to it along the shortest route, inspects it, and rides back to SS.
  • Dishonest employees tip one another off, so to stay unpredictable Byteasar must leave SS along a different track than he used on the previous trip. That is, two consecutive trips may not start down the same track out of SS.
  • Every station other than SS is inspected exactly once.
  • After inspecting the final station he does not return to SS.

Riding along any single track takes exactly one hour.

Byteasar will consider every station as a possible base SS. For each SS, find the smallest possible total travelling time of a valid tour, or report that no valid tour exists for that SS.

Input

The first line contains an integer nn (1n1,000,0001 \le n \le 1{,}000{,}000), the number of stations, numbered from 11 to nn. Each of the next n1n-1 lines contains two integers aa and bb (1a,bn1 \le a, b \le n, aba \ne b) separated by a single space, describing a track that directly connects stations aa and bb. Every track is listed exactly once.

Output

Print nn lines. Line ii must contain a single integer: the minimum total number of hours Byteasar needs to inspect every station when his base is S=iS = i, or 1-1 if no valid tour exists for S=iS = i.

Hint

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