#include<bits//stdc++.h>
using namespace std;

int highest;
int n;
int calculated[100000];
int up[100000], down[100000];
int superiors[100000];

int FindSuperior(int k)
{
    for(int i=0; i<n; i++)
    {
        if(up[i]==k)
        {
            if(calculated[down[i]]==0)
            {
                calculated[down[i]]=1;
                FindSuperior(down[i]);
            }
            superiors[k]+=superiors[down[i]];
        }
    }
    return superiors[k];
}

int main()
{
    cin>>n;
    int nothighest[n];
    for(int i=0; i<n; i++)
    {
        superiors[i]=0;
        nothighest[i]=0;
        calculated[i]=1;
    }
    for(int i=0; i<n-1; i++)
    {
        cin>>up[i]>>down[i];
        up[i]--;
        down[i]--;
        superiors[up[i]]=1;
        nothighest[down[i]]=1;
        calculated[up[i]]=0;
    }
    for(int i=0; i<n; i++)
    {
        if(nothighest[i]==0)
        {
            highest = i;
            break;
        }
    }

    FindSuperior(highest);
    for(int i=0; i<n; i++)
    {
        cout<<superiors[i]<<" ";
    }
    /*int m;
    cin>>m;
    int temp;
    for(int i=0; i<m; i++)
    {
        cin>>temp;
        cout<<superiors[temp-1]<<endl;
    }
    */
    return 0;
}
/*
6
6 1
6 5
1 2
1 3
3 4
*/
