#include <bits/stdc++.h>

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e5, lgsz = 18, trsz = 5 * nsz * lgsz;
int n, rt = 1, rs[nsz + 5], pr[nsz + 5], mx[nsz + 5], ans[nsz + 5];
vector<int> g[nsz + 5];

struct segment_tree {
    int sz, ls[trsz], rs[trsz], sum[trsz], del[trsz];
    
    void inline up(int u) {
        sum[u] = sum[ls[u]] + sum[rs[u]];
    }
    
    void inline down(int u, int l, int r) {
        int md = (l + r) >> 1;
        if (!del[u])  return;
        ls[u] = ls[u] ? ls[u] : ++sz;
        rs[u] = rs[u] ? rs[u] : ++sz;
        sum[ls[u]] += (md - l + 1) * del[u];
        sum[rs[u]] += (r - md) * del[u];
        del[ls[u]] += del[u];
        del[rs[u]] += del[u];
        del[u] = 0;
    }
    
    void set(int el, int er, int &u, int l = 1, int r = n) {
        if (!u)  return;
        u = u ? u : ++sz;
        down(u, l, r);
        int md = (l + r) >> 1;
        if (el <= md && ls[u]) {
            if (l >= el && md <= er) {
                ls[u] = 0;
            } else {
                set(el, er, ls[u], l, md);
            }
        }
        if (er > md && rs[u]) {
            if (md + 1 >= el && r <= er) {
                rs[u] = 0;
            } else {
                set(el, er, rs[u], md + 1, r);
            }
        }
        up(u);
    }
    
    void add(int el, int er, int val, int &u, int l = 1, int r = n) {
        u = u ? u : ++sz;
        if (l >= el && r <= er) {
            sum[u] += (r - l + 1) * val;
            del[u] += val;
            return;
        }
        down(u, l, r);
        int md = (l + r) >> 1;
        if (el <= md) {
            add(el, er, val, ls[u], l, md);
        }
        if (er > md) {
            add(el, er, val, rs[u], md + 1, r);
        }
        up(u);
    }
    
    int qry(int id, int u, int l = 1, int r = n) {
        if (l == r)  return sum[u];
        down(u, l, r);
        int md = (l + r) >> 1;
        return id <= md ? (ls[u] ? qry(id, ls[u], l, md) : 0) : (rs[u] ? qry(id, rs[u], md + 1, r) : 0);
    }
    
    int merge(int v1, int v2, int l = 1, int r = n) {
        if (!v1 || !v2)  return v1 | v2;
        sum[v1] += sum[v2];
        del[v1] += del[v2];
        if (l == r)  return v1;
        int md = (l + r) >> 1;
        ls[v1] = merge(ls[v1], ls[v2], l, md);
        rs[v1] = merge(rs[v1], rs[v2], md + 1, r);
        return v1;
    }
};
segment_tree tr;

void dfs(int u = rt) {
    loop (i, g[u].size()) {
        int v = g[u][i];
        if (v == pr[u])  continue;
        pr[v] = u;
        mx[v] = max(mx[u], u);
        dfs(v);
        rs[u] = tr.merge(rs[u], rs[v]);
    }
    if (u == rt)  return;
    tr.add(1, n, 1, rs[u]);
    if (u > mx[pr[u]]) {
        ans[u] = tr.qry(mx[u], rs[u]);
    } else {
        if (pr[u] < mx[pr[u]]) {
            ans[u] = 0;
        } else {
            ans[u] = tr.qry(mx[u], rs[u]) - tr.qry(mx[pr[u]], rs[u]);
        }
    }
    tr.set(1, u - 1, rs[u]);
}

void pre(int u = rt) {
    loop (i, g[u].size()) {
        int v = g[u][i];
        if (v == pr[u])  continue;
        ans[v] += ans[u];
        pre(v);
    }
}

int main() {
    scanf("%d", &n);
    cont (i, n - 1) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs();
    pre();
    circ (i, 2, n) {
        printf("%d ", ans[i]);
    }
}

Measured memory_bytes: 225780