#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vs vector<string>
typedef pair<string,int> card;
#define mark first
#define kazu second
const int inf=1e9+1;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

class Tree{
	int node;
	int degree;
	int parent;
	int sibling;
	int depth;
	int height;
	string type;
	vi children;
public:
	Tree(){}
	int get_node() const{return node;}
	void set_node(int a){node=a;}
	int get_degree() const{return degree;}
	void set_degree(int a){degree=a;}
	int get_parent() const{return parent;}
	void set_parent(int a){parent=a;}
	int get_sibling() const{return sibling;}
	void set_sibling(int a){sibling=a;}
	int get_depth() const{return depth;}
	void set_depth(int a){depth=a;}
	string get_type() const{return type;}
	void set_type(string s){type=s;}
	int get_children(int i) const{return children[i];}
	void set_children(int a){children.push_back(a);}
	int get_height() const{return height;}
	void set_height(int a){height=a;}
};

void depth(vector<Tree> &tree,int i);
int height(vector<Tree> &tree,int i);

int main(){
	int n,i,j;
	cin>>n;
	vector<Tree> tree(n);
	loop(i,0,n){
		tree[i].set_node(i);
		tree[i].set_parent(-1);
		tree[i].set_depth(-1);
	}
	int id,left,right,deg;
	loop(i,0,n){
		cin>>id>>left>>right;
		if(left!=-1&&right!=-1){
			deg=2;
			tree[left].set_sibling(right);
			tree[right].set_sibling(left);
			tree[left].set_parent(id);
			tree[right].set_parent(id);
			tree[id].set_children(left);
			tree[id].set_children(right);
		}else if(left==-1&&right==-1){
			deg=0;
		}else{
			deg=1;
			if(left!=-1){
				tree[left].set_sibling(right);
				tree[left].set_parent(id);
				tree[id].set_children(left);
			}else{
				tree[right].set_sibling(left);
				tree[right].set_parent(id);
				tree[id].set_children(right);
			}
		}
		tree[id].set_degree(deg);
	}
	loop(i,0,n){
		if(tree[i].get_parent()==-1){
			tree[i].set_depth(0);
			tree[i].set_type("root");
			tree[i].set_sibling(-1);
			break;
		}
	}
	depth(tree,i);
	height(tree,i);
	loop(i,0,n){
		cout<<"node "<<tree[i].get_node()<<": parent = "<<tree[i].get_parent();
		cout<<", sibling = "<<tree[i].get_sibling()<<", degree = "<<tree[i].get_degree();
		cout<<", depth = "<<tree[i].get_depth()<<", height = "<<tree[i].get_height();
		cout<<", "<<tree[i].get_type()<<endl;
	}
}
void depth(vector<Tree> &tree,int i){
	int j;
	loop(j,0,tree[i].get_degree()){
		tree[tree[i].get_children(j)].set_depth(tree[i].get_depth()+1);
	}
	if(tree[i].get_degree()==0){
		if(tree[i].get_type()!="root"){
			tree[i].set_type("leaf");
		}
	}else{
		if(tree[i].get_type()!="root"){
			tree[i].set_type("internal node");
		}
		loop(j,0,tree[i].get_degree()){
			depth(tree,tree[i].get_children(j));
		}
	}
}

int height(vector<Tree> &tree,int i){
	int j,a,b;
	if(tree[i].get_degree()==0){
		tree[i].set_height(0);
		return tree[i].get_height();
	}else if(tree[i].get_degree()==1){
		a=height(tree,tree[i].get_children(0));
		tree[i].set_height(a+1);
		return a+1;
	}else{
		a=height(tree,tree[i].get_children(0));
		b=height(tree,tree[i].get_children(1));
		a=max(a,b);
		tree[i].set_height(a+1);
		return a+1;
	}
}

Measured memory_bytes: 3228