#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<int>edge[200005];
int up[200005];
int mx[200005],dep[200005];
int n;
int UPP[200005][21];
void dfs(int v,int u,int d){
	UPP[v][0] = u;
	d = max(d,v);
	mx[v] = d;
	up[v] = u;
	if(u == -1) dep[v] = 0;
	else dep[v] = dep[u]+1;
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i]==u)continue;
		dfs(edge[v][i],v,d);
	}
}
vector<int>query[200005];
vector<int>query2[200005];
struct uf{
	int par[200005],ran[200005],sz[200005];
	void init(){ for(int i=0;i<200005;i++) par[i] = i,ran[i] = sz[i] = 0; }
	void make(int x){
		sz[x] = 1;
	}
	int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
	void unite(int x,int y){
		x = find(x); y = find(y); if(x==y) return;
		if(ran[x] < ran[y]){
		        par[x] = y;
		        sz[y] += sz[x];
		}
		else{
			par[y] = x;
			sz[x] += sz[y];
			if(ran[x] == ran[y]) ran[x]++;
		}
	}
	bool same(int x,int y){ return find(x)==find(y); }
	int SZ(int x){ return sz[find(x)];}
}cnt;
int C[200005];
int D[200005];
int go[200005];
int go2[200005];
int GO(int v,int sz){
	rep(j,21){
		if(((sz>>j)&1)) v = UPP[v][j];
	}
	return v;
}
vector<P>V;
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int a,b; scanf("%d%d",&a,&b);
		edge[a].pb(b);
		edge[b].pb(a);
	}
	dfs(1,-1,0);
	rep(j,20) for(int i=1;i<=n;i++){
		if(UPP[i][j]==-1) UPP[i][j+1] = -1;
		else UPP[i][j+1] = UPP[UPP[i][j]][j];
	}
	for(int i=2;i<=n;i++){
		if(dep[i] <= 2) continue;
		int x = up[i];
		int y = up[x];
		y = mx[y];
		query[y].pb(i);
		//cout<<y<<" "<<i<<endl;
	}
	for(int i=2;i<=n;i++){
		if(dep[i] <= 1) continue;
		int x = up[i];
		x = mx[x];
		query2[x].pb(i);
		//cout<<x<<" "<<i<<endl;
	}
	cnt.init();
	memset(go,-1,sizeof(go));
	memset(go2,-1,sizeof(go2));
	for(int i=1;i<=n;i++){
		for(int j=0;j<query[i].size();j++){
			int act = up[query[i][j]];
			for(int k=0;k<edge[act].size();k++){
				if(edge[act][k] == query[i][j]) continue;
				C[query[i][j]] += cnt.SZ(edge[act][k]);
			}
			C[query[i][j]]++;
			go[query[i][j]] = GO(query[i][j],dep[query[i][j]]-dep[i]-1);
		}
		for(int j=0;j<query2[i].size();j++){
			int act = query2[i][j];
			if(act >= i){
    			for(int k=0;k<edge[act].size();k++){
    				D[query2[i][j]] += cnt.SZ(edge[act][k]);
    				
    			//	if(query2[i][j] == 2) cout<<edge[act][k]<<" t "<<cnt.SZ(edge[act][k])<<endl;
    			}
    			D[query2[i][j]]++;
			}
			else{
			    {
    				D[query2[i][j]] += cnt.SZ(act);
    			//	if(query2[i][j] == 2) cout<<edge[act][k]<<" t "<<cnt.SZ(edge[act][k])<<endl;
    			}
			}
			go2[query2[i][j]] = GO(query2[i][j],dep[query2[i][j]]-dep[i]-1);
		}
		cnt.make(i);
		for(int j=0;j<edge[i].size();j++){
			if(edge[i][j] <= i) cnt.unite(i,edge[i][j]);
		}
	}
	//for(int i=2;i<=5;i++) cout<<i<<" "<<C[i]<<" "<<D[i]<<endl;
	for(int i=2;i<=n;i++) V.pb(mp(dep[i],i));
	SORT(V);
	for(int i=0;i<V.size();i++){
		int v = V[i].sc; 
		if(go[v] == -1) continue;
		C[v] += C[go[v]];
	}
	for(int i=0;i<V.size();i++){
		int v = V[i].sc; 
		if(go2[v] == -1) continue;
		D[v] += C[go2[v]];
	}
	for(int i=2;i<=n;i++) printf("%d\n",D[i]+1);
}

Measured memory_bytes: 61940