Problem

A graph is given in which N vertices, each numbered from 1 to N, are connected by N-1 undirected edges. For each vertex, output the shortest number of steps to start from that vertex and visit all vertices.

However, one step is to follow one side from one vertex and move to another vertex.

Constraints

* 2 ≤ N ≤ 105
* 1 ≤ ui, vi ≤ N (1 ≤ i ≤ N-1)
* ui ≠ vi
* The graph given is concatenated

Input

The input is given in the following format.


N
u1 v1
..
..
..
uN−1 vN−1


The first line is given one integer N.
In the following N-1 line, the integers ui and vi representing the vertex numbers at both ends of the i-th side are given on the i-th line, separated by blanks.

Output

Output the shortest number of steps to visit all vertices starting from vertex i on the i-th line from vertex 1 to vertex N.

Examples

Input

2
1 2


Output

1
1


Input

6
1 2
1 3
3 4
3 5
5 6


Output

7
6
8
7
7
6
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
///////////////////////////

#define N 100005
vector<ll>v[N];
ll dis[N];
ll dfs(ll id ,ll par){
    for(auto x:v[id]){
        if(x==par)continue;
        Max(dis[id],dfs(x,id)+1);
    }
    return dis[id];
}
ll dis2[N];
void dfs2(ll id,ll d_par,ll par){
    for(auto x:v[id]){
        if(x==par)Max(dis2[id],d_par);
        else Max(dis2[id],dis[x]+1);
    }
    vector<l_l>come;
    for(auto x:v[id]){
        if(x==par){
            come.pb({d_par,-1});
        }else{
            come.pb({dis[x]+1,x});
        }
    }
    come.pb({0,-1});
    sort(come.rbegin(),come.rend());
    for(auto x:v[id]){
        if(x==par)continue;
        if(come[0].se==x){
            dfs2(x,come[1].fi+1,id);
        }else{
            dfs2(x,come[0].fi+1,id);
        }
    }
}
int main(){fastio
    ll n;cin>>n;
    rep(i,1,n-1){
        ll a,b;cin>>a>>b;
        v[a].pb(b);v[b].pb(a);
    }
    dfs(1,-1);
    //rep(i,1,n)cout<<dis[i]<<" ";cout<<endl;
    dfs2(1,0,-1);
    rep(i,1,n)cout<<2*(n-1)-dis2[i]<<endl;
    return 0;
}

