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

void DFS(int source, vector<int> adjList[], vector<int> &parent, vector<int> &visited, vector<int> &heights){
	visited[source]=1;
	for(auto it : adjList[source]){
		if(!visited[it]){
			parent[it]=source;
			DFS(it, adjList, parent, visited, heights);
		}
	}
	int h=0;
	for(auto child : adjList[source]){
		//this means that child node is actually the parent
		if(child==parent[source]){
			//no op
		}
		else{
			h=max(h, heights[child]);
		}
	}
	heights[source]=1+h;
}

int main() {
	int n;
	cin>>n;
	vector<int> adjList[n+1];
	vector<int> parent(n+1);
	vector<int> visited(n+1);
	vector<int> heights(n+1);
	for(int i=1;i<=n-1;i++){
		int x,y;
		cin>>x>>y;
		adjList[x].push_back(y);
		adjList[y].push_back(x);
	}
	DFS(1, adjList, parent, visited, heights);
	for(int i=1; i<=n; i++){
		cout<<"height of node "<<i<<" : "<<heights[i]<<"\n";
	}
	return 0;
}