#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

template<typename T> T& updMin(T& a, T const& b) { if (b < a) a = b; return a; }
template<typename T> T& updMax(T& a, T const& b) { if (a < b) a = b; return a; }

// ========================================================================= //

const int N = 200179;

struct DSU {
    int p[N], s[N];
    DSU() {
        for (int i = 0; i < N; ++i) {
            p[i] = -1;
            s[i] = 1;
        }
    }
    int get(int x) {
        return p[x] == -1 ? x : p[x] = get(p[x]);
    }
    void merge(int x, int y) {
        x = get(x);
        y = get(y);
        if (x != y) {
            p[x] = y;
            s[y] += s[x];
        }
    }
    int size(int x) {
        return s[get(x)];
    }
} dsu;

int n;
vector<int> e[N];
int p[N];
int pmax[N];
int pmaxi[N];

void dfs(int v, int cp, int cm, int cmi = -1) {
    p[v] = cp;
    pmax[v] = cm;
    pmaxi[v] = cmi;
    int i = 0;
    for (int nv : e[v]) {
        if (nv != cp)
            dfs(nv, v, max(cm, v), cm < v ? i : cmi);
        ++i;
    }
}

vector<int> order[N];
int d[N];
vector<int> d1[N];
int ans[N];
vector<int> ans1[N];

void dfs1(int v) {
    if (v == 0) {
        ans[v] = 1;
        ans1[v].resize(sz(e[v]), 1);
    } else {
        ans[v] = d[v] + ans1[pmax[v]][pmaxi[v]];
        if (v > pmax[v]) {
            for (int i = 0; i < sz(e[v]); ++i) {
                if (e[v][i] == p[v])
                    ans1[v].push_back(0);
                else
                    ans1[v].push_back(d1[v][i] + ans1[pmax[v]][pmaxi[v]]);
            }
        }
    }
    for (int nv : e[v])
        if (nv != p[v])
            dfs1(nv);
}

int main() {
    ios::sync_with_stdio(false);

    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        e[x].push_back(y);
        e[y].push_back(x);
    }

    dfs(0, -1, -1);
    for (int i = 1; i < n; ++i)
        order[pmax[i]].push_back(i);

    for (int v = 0; v < n; ++v) {
        for (int x : order[v]) {
            if (x < v)
                d[x] = dsu.size(x);
            else {
                d[x] = 1;
                for (int nx : e[x])
                    if (nx < v)
                        d[x] += dsu.size(nx);
                for (int nx : e[x])
                    d1[x].push_back(d[x] - ((nx < v || p[x] == nx) ? dsu.size(nx) : 0));
            }
        }
        for (int nv : e[v])
            if (nv < v)
                dsu.merge(v, nv);
    }

    dfs1(0);
    for (int i = 1; i < n; ++i)
        cout << ans[i] - 1 << " ";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 208120