#include<bits/stdc++.h>
using namespace std;
#define int long long
int rv[30];
struct node{
  int id,left,right,par,sib,deg,dep,hei;
  string type;
  node(){par=sib=-1;}
  string val(){
    string res;
    res+="node "+to_string(id);
    res+=": parent = " +to_string(par);
    res+=", sibling = "+to_string(sib);
    res+=", degree = " +to_string(deg);
    res+=", depth = "  +to_string(dep);
    res+=", height = " +to_string(hei);
    res+=", "+type;
    return res;
  }
};
node t[30];
int dfs(int v,int d){
  t[v].dep=d;
  t[v].type="internal node";
  if(~t[v].left&&~t[v].right){
    t[rv[t[v].left ]].sib=t[v].right;
    t[rv[t[v].right]].sib=t[v].left;
    t[v].deg=2;
    return t[v].hei=max(dfs(rv[t[v].left],d+1),dfs(rv[t[v].right],d+1))+1;
  }else if(~t[v].left){
    t[v].deg=1;
    return t[v].hei=dfs(rv[t[v].left ],d+1)+1;
  }else if(~t[v].right){
    t[v].deg=1;
    return t[v].hei=dfs(rv[t[v].right],d+1)+1;
  }else{
    t[v].type="leaf";
    t[v].deg=0;
    return t[v].hei=0;
  }
}
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>t[i].id>>t[i].left>>t[i].right;
  for(int i=0;i<n;i++) rv[t[i].id]=i;
  for(int i=0;i<n;i++){
    //cout<<t[i].id<<":"<<t[i].left<<":"<<t[i].right<<endl;
    if(~t[i].left)  t[rv[t[i].left ]].par=t[i].id;
    if(~t[i].right) t[rv[t[i].right]].par=t[i].id;
  }
  for(int i=0;i<n;i++) if(t[i].par==-1) dfs(i,0),t[i].type="root";
  for(int i=0;i<n;i++) cout<<t[rv[i]].val()<<endl;
  return 0;
}