#include<iostream>
#include<cstdio>
using namespace std;
struct edge{int to,next;}e[400005];int tot=0,last[200005],sz1[200005],sz2[200005],maxx[200005],ans[200005];
inline void adde(int u,int v) {e[++tot]=(edge){v,last[u]},last[u]=tot;return;}
inline void inse(int u,int v) {adde(u,v),adde(v,u);return;}
void dfs1(int root,int fa,int lim,int* sz) {sz[root]=1;
    for (register int i=last[root];i;i=e[i].next) if (e[i].to^fa&&e[i].to<lim) dfs1(e[i].to,root,lim,sz),sz[root]+=sz[e[i].to];
    return;
}void dfs2(int root,int fa) {maxx[root]=max(maxx[fa],root);
    for (register int i=last[root];i;i=e[i].next) if (e[i].to^fa) dfs2(e[i].to,root);
    if (maxx[root]==root) dfs1(root,fa,maxx[fa],sz1),dfs1(root,fa,maxx[root],sz2);return;
}void dfs3(int root,int fa) {
    if (root^1) {
        if (maxx[root]==root) ans[root]=sz1[root];
        else if(maxx[fa]==fa) ans[root]=sz2[root]-sz1[root];ans[root]+=ans[fa];
    }for (register int i=last[root];i;i=e[i].next) if (e[i].to^fa) dfs3(e[i].to,root);return;
}int main() {int n,u,v;
    scanf("%d",&n);for (register int i=1;i<n;++i) scanf("%d%d",&u,&v),inse(u,v);
    dfs2(1,0),dfs3(1,0);for (register int i=2;i<=n;++i) printf("%d ",ans[i]);return 0;
}