#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> grh;
vector<int> prt, mxv;
vector<map<int, int>> mps;
vector<int> dp;
int fnc (int crr, int c) {
  auto& mp = mps[crr];
  if (mp.find(c) != mp.end()) return mp[c];
  int ret = 1;
  for (int nxt : grh[crr]) if (nxt != prt[crr]) {
      prt[nxt] = crr;
      if (nxt < c) {
        ret += fnc(nxt, c);
      }
  }
  mp[c] = ret;
  return ret;
}
void dfs (int crr) {
  int p = prt[crr];
  int d = mxv[prt[p]];
  int c = mxv[p] = max(d, p);
  if (crr < d) {
    dp[crr] = dp[p] + fnc(crr, c) - fnc(crr, d);
  } else if (crr > d) {
    dp[crr] = dp[p] + fnc(crr, c);
  }
  for (int nxt : grh[crr]) if (nxt != prt[crr]) {
      prt[nxt] = crr;
      dfs(nxt);
  }
}
int main() {
  cin >> n;
  grh.resize(n);
  prt.resize(n, 0);
  mxv.resize(n, 0);
  mps.resize(n);
  dp.resize(n, 0);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    grh[--a].push_back(--b);
    grh[b].push_back(a);
  }
  dfs(0);
  for (int i = 1; i < n; i++) {
    cout << dp[i];
    if (i < n - 1) {
      cout << ' ';
    } else {
      cout << '\n';
    }
  }
  return 0;
}