#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pii pair<int,int>
#define mkp make_pair

int N;
vector<int> rvs[202020];
int prv[202020];
vector<int> chrvs[202020];

int rt[202020];
int mxp[202020];

int mk[202020];
int ct[202020];

int tl1[202020];
int tl2[202020];
int anss[202020];

int i,j,h;

void sett(int n){
    int i;
    fornum(i,0,rvs[n].size()){
        if(prv[n]!=rvs[n][i]){
            {
                int nn = rvs[n][i];
                prv[nn] = n;
                mxp[nn] = n > mxp[n] ? n : mxp[n];
                chrvs[n].push_back(nn);
            }
            sett(rvs[n][i]);
        }
    }
}

void dfs(int n){
    int i;
    fornum(i,0,chrvs[n].size()){
        dfs(chrvs[n][i]);
    }
    tl1[n]++;
    if(n<mxp[prv[n]]){
        if (n> mxp[mxp[n]])
        {
            tl2[prv[n]] += tl1[n];
        }else{
            tl1[prv[n]] += tl1[n];
        }
        tl1[n] = 0;
    }
    if(mxp[n]==prv[n]){
        tl1[n] += tl2[n];
    }else{
        tl2[prv[n]] += tl2[n];
    }
}
void rslt(int n){
    int i;
    anss[n] = anss[prv[n]] + tl1[n];
    fornum(i,0,chrvs[n].size()){
        rslt(chrvs[n][i]);
    }
}


int main(){
    scanf("%d", &N);
    fornum(i,1,N){
        int a, b;
        scanf("%d%d",&a,&b);
        rvs[a].push_back(b);
        rvs[b].push_back(a);
    }

    sett(1);
    /*
    fornum(i,0,N){
        printf("%d,%d,%d_",prv[i+1],mxp[i+1],chrvs[i+1].size() );
    }*/
    dfs(1);
    tl1[1] = 0;
    rslt(1);

    fornum(i,1,N){
        printf("%d ",anss[i+1]);
    }

    return 0;
}