#include <bits/stdc++.h>

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, dp[max_n], mx[max_n], p[max_n], tot[max_n];
vector<int> g[max_n], f[max_n];

void dfs0(int v) {
    for (int i = 0; i < g[v].size(); ++i) {
        if (g[v][i] == p[v]) {
            swap(g[v][i], g[v].back());
            g[v].pop_back();
            break;
        }
    }
    for (int i = 0; i < g[v].size(); ++i) {
        p[g[v][i]] = v;
        mx[g[v][i]] = max(mx[v], v);
        dfs0(g[v][i]);
    }
}

int dfs3(int v, int mx) {
    if (v >= mx) {
        return 0;
    }
    int res = 1;
    for (int to : g[v]) {
        res += dfs3(to, mx);
    }
    return res;
}

void dfs1(int v) {
    for (int to : g[v]) {
        dfs1(to);
    }
    f[v].resize(g[v].size());
    if (v < mx[v]) {
        for (int i = 0; i < g[v].size(); ++i) {
            const int to = g[v][i];
            if (to < mx[v]) {
                f[v][i] = tot[to] + 1;
            }
            tot[v] += f[v][i];
        }
    } else {
        for (int i = 0; i < g[v].size(); ++i) {
            f[v][i] = dfs3(g[v][i], mx[v]);
            tot[v] += f[v][i];
        }
    }
}

void dfs2(int v) {
    for (int i = 0; i < g[v].size(); ++i) {
        const int to = g[v][i];
        dp[to] = 1 + dp[v] + tot[to] - f[v][i];
        dfs2(to);
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i < n; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs0(1);
    dfs1(1);
    dfs2(1);
    for (int i = 2; i <= n; ++i) {
        printf("%d ", dp[i]);
    }
    puts("");
    return 0;
}
