#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class RootedNode{
public:
	vector<ll> parent;
	ll depth,dist,height;
	RootedNode():depth(0),dist(0),height(0){}
};

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	map<int,int> input;
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		input[v]++;
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class RootedTree{
	int parent_size;

	ll DFS(ConnectNodeInfo& connection,ll child,ll parent,ll dep,ll dist){
		node[child].parent[0] = parent;
		node[child].depth = dep;
		max_depth = max(max_depth,dep);
		node[child].dist = dist;

		ll height=0;
		for(int i = 0;i < connection[child].size();i++){
			if(connection[child][i].first != parent){
				height = max(height,DFS(connection,connection[child][i].first,child,dep+1,dist+connection[child][i].second)+1LL);
			}
		}
		node[child].height = height;
		return height;
	}
public:
	vector<RootedNode> node;
	ll max_depth;

	RootedTree(ConnectNodeInfo& connection,int root){
		auto connection_size = connection.size();
		parent_size = 1;
		while((1LL<<parent_size)<connection_size) parent_size++;

		node.resize(connection_size);
		for(auto& x:node) x.parent.resize(parent_size,-1);
		DFS(connection,root,-1,0,0);
		for(int k=0;k<parent_size-1;k++){
			for(int v=0,ev=connection_size;v<ev;v++){
				if(node[v].parent[k] < 0) node[v].parent[k+1] = -1;
				else node[v].parent[k+1] = node[node[v].parent[k]].parent[k];
			}
		}
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N=in();
	ConnectNodeInfo connect(N);
	REP(i,N){
		int u=in(),v1=in(),v2=in();
		if(v1!=-1) connect.AddDirectionalConnection(u,v1,1);
		if(v2!=-1) connect.AddDirectionalConnection(u,v2,1);
	}
	int root;
	REP(i,N){
		if(connect.input[i]==0){
			root = i;
			break;
		}
	}
	RootedTree tree(connect,root);

	REP(i,N){
		int parent = tree.node[i].parent[0];
		cout << "node " << i << ": parent = " << parent << ", sibling = ";
		if(tree.node[i].depth==0){
			cout << "-1, degree = ";
		}
		else{
			int sibling=-1;
			for(int j=0,ej=connect[parent].size();j<ej;j++){
				if(connect[parent][j].first!=i){
					sibling = connect[parent][j].first;
					break;
				}
			}
			cout << sibling << ", degree = ";
		}
		cout << connect[i].size() << ", depth = " << tree.node[i].depth << ", height = " << tree.node[i].height;
		if(tree.node[i].depth==0){
			out(", root");
		}
		else if(connect[i].empty()) out(", leaf");
		else{
			out(", internal node");
		}
	}
	
	return 0;
}



Measured memory_bytes: 3204