#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }

class Union_find
{
public:
    vector<int> par;
    vector<int> sz;
 
    Union_find(int N){
        par = vector<int>(N);
        REP(i, N) par[i] = i;
        sz = vector<int>(N, 1);
    }
 
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
 
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
 
        if(sz[x] < sz[y]){
            par[x] = y;
            sz[y] += sz[x];
        }else{
            par[y] = x;
            sz[x] += sz[y];
        }
    }
 
    bool is_union(int x, int y){
        x = find(x);
        y = find(y);
        return x == y;
    }
 
    int union_size(int x){
        return sz[find(x)];
    }
 
};

struct edge{int to, cost;};

class Graph
{
public:
    int V;
    vector<vector<edge>> G;
    vec ans, M, par;
    map<Pii, int> memo;

    Graph(int V): V(V){
        G = vector<vector<edge>>(V, vector<edge>(0));
        ans = vec(V);
        M = vec(V, -1);
        par = vec(V);
    }

    void add_edge(int from, int to, int cost){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    void calc_par(int v, int p){
        par[v] = p;
        if(p != -1) M[v] = max(M[p], p);
        REP(k, G[v].size()) if(G[v][k].to != p) calc_par(G[v][k].to, v);
    }

    int Q(int v, int x){
        if(memo.count(Pii(v, x))) return memo[Pii(v, x)];
        int n = 0;
        REP(k, G[v].size()) if(G[v][k].to != par[v] && G[v][k].to < x) n += 1 + Q(G[v][k].to, x);
        return memo[Pii(v, x)] = n;
    }

    void dfs(int v){
        if(v == 0) ans[v] = 0;
        else if(par[v] == 0) ans[v] = 1;
        else{
            if(v > M[par[v]]){
                ans[v] = ans[par[v]] + Q(v, M[v]) + 1;
            }else{
                ans[v] = ans[par[v]] + Q(v, M[v]) - Q(v, M[par[v]]);
            }
        }
        REP(k, G[v].size()) if(G[v][k].to != par[v]) dfs(G[v][k].to);
    }

    void showans(){
        FOR(i, 1, V) cout << ans[i] << " ";
    }

};

signed main(){

    int N, a, b; cin >> N;
    Graph G(N);
    REP(i, N - 1){
        cin >> a >> b;
        G.add_edge2(a - 1, b - 1, 0);
    }
    G.calc_par(0, -1);
    G.dfs(0);
    G.showans();
    
    return 0;
}

Measured memory_bytes: 50048