#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> grh;
vector<int> upr, sz, ssz, dp, prt;
void dfs (int crr = 0, int prt = 0) {
  upr[crr] = max(upr[prt], prt);
  sz[crr] = 1;
  if (upr[upr[crr]] > crr) {
    ssz[crr] = 1;
  } else {
    ssz[crr] = 0;
  }
  for (int nxt : grh[crr]) if (nxt != prt) {
    dfs(nxt, crr);
    if (upr[crr] > nxt) {
      if (upr[crr] > crr) {
        sz[crr] += sz[nxt];
      } else {
        sz[crr] += ssz[nxt];
      }
    }
    if (upr[upr[crr]] > crr && upr[upr[crr]] > nxt) {
      ssz[crr] += ssz[nxt];
    }
  }
}
void efs (int crr = 0, int prt = 0) {
  dp[crr] = dp[prt];
  if (upr[prt] > prt && upr[prt] < crr) {
    dp[crr] += sz[crr];
  }
  if (upr[prt] < prt) {
    dp[crr] += sz[crr] - ssz[crr];
  }
  for (int nxt : grh[crr]) if (nxt != prt) {
    efs(nxt, crr);
  }
}
int main() {
  int n;
  cin >> n;
  grh.resize(n);
  upr.resize(n, 0);
  sz.resize(n, 0);
  ssz.resize(n, 0);
  dp.resize(n, 1);
  prt.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();
  efs();
  for (int i = 1; i < n; i++) {
    cout << dp[i];
    if (i < n - 1) {
      cout << ' ';
    } else {
      cout << '\n';
    }
  }
  return 0;
}
