// 2018, Sayutin Dmitry.

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back

#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;

template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V> using ordered_map = tree<K, V, std::less<K>, rb_tree_tag, tree_order_statistics_node_update>;

// HOW TO USE ::
// -- order_of_key(10) returns the number of elements in set/map strictly less than 10
// -- *find_by_order(10) returns 10-th smallest element in set/map (0-based)

bool ANS = false;

const int max_n = 2.1e5;
map<int, int> queries_by_mx[max_n];

int tin[max_n], tout[max_n], par[max_n];

ordered_set<int> dsu[max_n];
int where[max_n];


int query(const vector<vector<int>>& graph, int v, int p, int MX) {
    if (not ANS) {
        queries_by_mx[MX][v] = 0;
        return 0;
    } else {
        return queries_by_mx[MX][v];
        
        if (v > MX)
            return 0;
        
        int ans = 1;
        for (int u: graph[v])
            if (u != p)
            ans += query(graph, u, v, MX);
        
        return ans;
    }
}

void merge(int a, int b) {
    if (not (SZ(dsu[a]) <= SZ(dsu[b])))
        std::swap(a, b);

    for (auto elm: dsu[a]) {
        where[elm] = b;
        dsu[b].insert(elm);
    }

    dsu[a].clear();
}

void kukarek(int n, const vector<vector<int>>& graph) {
    for (int mx = 0; mx < n; ++mx) {
        for (int u: graph[mx])
            if (u <= mx) {
                merge(where[tin[u]], where[tin[mx]]);
            }

        for (auto& qr: queries_by_mx[mx]) {
            if (qr.first > mx)
                qr.second = 0;
            else {
                int wh = where[tin[qr.first]];
                qr.second = dsu[wh].order_of_key(tout[qr.first])
                    - dsu[wh].order_of_key(tin[qr.first]);
            }
        }
    }
}


void init(const vector<vector<int>>& graph, int v, int p, int& cur_t) {
    tin[v] = cur_t++;

    par[v] = p;
    for (int u: graph[v])
        if (u != p)
            init(graph, u, v, cur_t);
    
    tout[v] = cur_t;
}

void zhfs(const vector<vector<int>>& graph, vector<int>& ans, int v, int p, int up_mx, int acc) {
    acc += 1; // count new vertex in
    ans[v] = acc;
    for (int u: graph[v])
        if (u != p)
            ans[v] += query(graph, u, v, up_mx);

    for (int u: graph[v])
        if (u != p)
            acc += query(graph, u, v, up_mx);

    for (int u: graph[v])
        if (u != p) {
            int tmp = query(graph, u, v, up_mx);
            zhfs(graph, ans, u, v, max(up_mx, v), acc - tmp);
        }
}

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int n = input<int>();
    vector<vector<int>> graph(n);

    for (int i = 1; i != n; ++i) {
        int v = input<int>() - 1;
        int u = input<int>() - 1;

        graph[v].push_back(u);
        graph[u].push_back(v);
    }

    int cur_t = 0;
    init(graph, 0, -1, cur_t);

    for (int i = 0; i != n; ++i)
        dsu[i].insert(i), where[i] = i;
    
    vector<int> ans(n);
    zhfs(graph, ans, 0, -1, 0, 0);

    kukarek(n, graph);
    
    std::fill(ALL(ans), 0);
    ANS = 1;
    zhfs(graph, ans, 0, -1, 0, 0);
    
    ans.erase(ans.begin());
    for (auto el: ans)
        cout << el - 1 << " ";
    cout << "\n";
    
    return 0;
}


Measured memory_bytes: 80384