#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define vll vector<ll>
#define vst vector<string>
#define vvll(a,h,w) vector<vll> a(h,vll(w))
#define dou(s) atof(s.c_str())
#define lon(s) atoll(s.c_str())
#define str(n) to_string(n)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define fion(n) fixed<<setprecision(n)
#define endl "\n"
#define OR ||
#define AND &&
#define NOT !
#define line(s) getline(cin,s)
#define mav(a) (*max_element(ALL(a)))
#define miv(a) (*min_element(ALL(a)))
#define prque priority_queue
#define MOD 1000000007ll
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

//ペア配列の整理
struct pea{ll n,m;};
void msort(vector<pea> &a,ll k=634){
  struct hikakukansu{
    static bool unstable(const pea &x,const pea &y){return x.m<y.m;}
    static bool stable(const pea &x,const pea &y){return (x.m==y.m?x.n<y.n:x.m<y.m);}
  };
  if(k==634)sort(ALL(a),hikakukansu::unstable);
  else sort(ALL(a),hikakukansu::stable);
}

//nCk(mod p)
ll fac[510000],finv[510000],inv[510000];
void cmodf(ll p=MOD){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  rep(i,2,510000){
    fac[i]=fac[i-1]*i%p;
    inv[i]=p-inv[p%i]*(p/i)%p;
    finv[i]=finv[i-1]*inv[i]%p;
  }
}
ll cmod(ll n,ll k,ll p=MOD){
  return fac[n]*(finv[k]*finv[n-k]%p)%p;
}

//keyの小さい方から探していった時に初めてvalueがjoken以上になる時のkey（keyが増えたらvalueも増えるか同じになるとき）
ll value(ll key){
  /*変更*/
}
ll mini(ll lkey,ll rkey/*ここも調べる*/,ll joken){
  ll mkey;
  while(lkey!=rkey){
    mkey=(lkey+rkey)/2;
    if(value(mkey)>=joken)rkey=mkey;
    else lkey=mkey+1;
  }
  return rkey;
}

//最大公約数
ll gcd(vector<ll> a){
	rep(i,1,a.size()){
		ll k=a[i-1]%a[i];
		while(k!=0){
			a[i-1]=a[i];
			a[i]=k;
			k=a[i-1]%a[i];
		}
	}
	return a.back();
}

//最小公倍数
ll lcm(vector<ll> a){
	ll n;
	rep(i,1,a.size()){
		n=a[i-1]*a[i];
		ll k=a[i-1]%a[i];
		while(k!=0){
			a[i-1]=a[i];
			a[i]=k;
			k=a[i-1]%a[i];
		}
		n/=a[i];
		a[i]=n;
	}
	return n;
}

//Find_after_Sort or Find_String
ll fist(const vector<ll> &a,ll n){
	if(a.back()<n)return -1;
	ll k=lower_bound(ALL(a),n)-a.begin();
	if(a[k]==n)return k;
	return -1;
}
ll fist(string s,char c){return (int)s.find(c);}
ll fist(string s,string t){return (int)s.find(t);}

//再帰関数
void depth(vll &p,vll &k,vll &c,vll &d,vll &h,vector<vll> &cm,ll nd,ll i){
	d[i]=nd;
	rep(j,0,c[i])depth(p,k,c,d,h,cm,nd+1,cm[i][j]);
}
void height(vll &p,vll &k,vll &c,vll &d,vll &h,ll nh,ll i){
	h[i]=max(h[i],nh);
	if(p[i]!=-1)height(p,k,c,d,h,h[i]+1,p[i]);
}

//アルゴリズム
void solve(){
	ll n,x,y,z;cin>>n;
	vll p(n,-1),k(n,-1),c(n),d(n),h(n,0);
	vvll(cm,n,0);
	rep(i,0,n){
		cin>>x>>y>>z;
		if(y!=-1 AND z!=-1){
			c[x]=2;
			k[y]=z;k[z]=y;
			p[y]=x;p[z]=x;
			cm[x].push_back(y);
			cm[x].push_back(z);
		}else if(y!=-1){
			c[x]=1;
			p[y]=x;
			cm[x].push_back(y);
		}else if(z!=-1){
			c[x]=1;
			p[z]=x;
			cm[x].push_back(z);
		}else{
			c[x]=0;
		}
	}
	rep(i,0,n)if(p[i]==-1){depth(p,k,c,d,h,cm,0,i);break;}
	rep(i,0,n)if(c[i]==0)height(p,k,c,d,h,0,i);
	rep(i,0,n){
		cout<<"node "<<i<<": parent = "<<p[i]<<", sibling = "<<k[i]<<", degree = "<<c[i]<<", depth = "<<d[i]<<", height = "<<h[i]<<", ";
		if(p[i]==-1)cout<<"root"<<endl;
		else if(h[i]==0)cout<<"leaf"<<endl;
		else cout<<"internal node"<<endl;
	}
}


Measured memory_bytes: 3232