#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
     
int dep[1000];
int deg[1000];
int dad[1000];
int lef[1000];
int rig[1000];
int hei[1000];
int sib[1000];
int in[1000];
 
int depth(int now,int prev){
  if(deg[now] == 0){
    dep[now] = dep[prev]+1;
    return 0;
  }
    dep[now] = dep[prev]+1;
    //cout << "now = " << now << ", prev = " << prev << endl;
    //cout << dep[now] << endl;
    if(lef[now] != -1){//cout << "In1" << endl;
    depth(lef[now],now);
    }
    if(rig[now] != -1){//cout << "In2" << endl;
      depth(rig[now],now);
    }
 
   
}
 
int heich(int now,int above){
  if(dad[now] == -1)return 0;
 
  if(hei[now]+1 > hei[above]){ 
    hei[above]=hei[now]+1;
    heich(above,dad[above]);
  }
 
}
 
int main(){
  int n,id,L,R;
  
 
  scanf("%d\n",&n);
 
  for(int i=0;i<1000;i++){
    dad[i]=-1;
    lef[i]=-1;
    rig[i]=-1;
    dep[i]=0;
    hei[i]=0;
    sib[i]=-1;
    deg[i]=0;
  }
 
  for(int i=0;i<n;i++){
    scanf("%d %d %d\n",&id,&L,&R);
    dad[L]=dad[R]=id;
    lef[id] = L;
    rig[id] = R;
    if(!(L==-1 || R==-1)){
 
      sib[L]=R;
      sib[R]=L;
    }
    if(L+R == -2){
      deg[id]=0;
    }
    else if(L == -1 || R == -1){
      deg[id]=1;
    }
    else deg[id] = 2;
 
 
    if(L == -1){
      dep[R]=dep[id]+1;
    }
    else if(R == -1){
      dep[L]=dep[id]+1;
    }else{
      dep[L]=dep[id]+1;
      dep[R]=dep[id]+1;
    }
    if(deg[L] != 0){
      if(lef[L] == -1){
 
    depth(rig[L],L);
      }
      else if(rig[L] == -1){
    depth(lef[L],L);
      }
      else{
    depth(rig[L],L);
    depth(lef[L],L);
      }
    }
    if(deg[R] != 0){
      if(lef[R] == -1){
    depth(rig[R],R);
      }
      else if(rig[R] == -1){
    depth(lef[R],R);
      }
      else{
    depth(rig[R],R);
    depth(lef[R],R);
      }
    }
 
    /*
    if(L+R != -2){ // hukasa   
      if(deg[L] != 0){
    if(lef[L] == -1){
      depth(rig[L],L);
    }
    else if(rig[L] == -1){
    depth(lef[L],L);
    }
    else{
      depth(rig[L],L);
      depth(lef[L],L);
    }
 
      }
      if(deg[R] != 0){
    depth(rig[R],R);
      }
    }
    else if(L == -1){
      dep[R]=dep[id]+1;
      if(deg[R] != 0){
    depth(rig[L],L);
      }
    }
    else{
      dep[L]=dep[id]+1;
      if(deg[L] != 0){
    depth(lef[L],L);
      }
    }
    */
 
  }
 
  for(int i=0;i<n;i++){ //
    if(lef[i] == -1 && rig[i] == -1){
      heich(i,dad[i]);
    }
  } //
 
  for(int i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,dad[i],sib[i],deg[i],dep[i],hei[i]);
    if(dad[i] == -1){
      printf("root\n");
    }
    else if(hei[i] == 0){
      printf("leaf\n");
    }
    else printf("internal node\n");
 
  }
 
 
  return 0;
}
