#include<iostream>
#define N 100001
#define INF 10000
using namespace std;


struct Node{
  int p,l,r;
};
Node t[N];

int sibling(int x){
  return t[x].r;
}

int dep(int x){
  int cnt=0;
  if(t[x].p>=0) cnt=dep(t[x].p)+1;
  return cnt;
}

int height(int x){
  int cntl=0,cntr=0;
  if(t[x].l>=0)cntl=height(t[x].l)+1;
  if(t[x].l>=0 && t[t[x].l].r>=0) cntr=height(t[t[x].l].r)+1;
  if(cntl<cntr)return cntr;
  else  return cntl;
}

int degree(int x){
  int cnt=0;
  if(t[x].l>=0)cnt++;
  if(t[x].l>=0 &&t[t[x].l].r>=0)cnt++;
  return cnt;
}

int main(){
  int n,id,c;
  cin>>n;
  for(int i=0;i<n;i++)t[i].l=-1,t[i].p=-1,t[i].r=-1;

  for(int i=0;i<n;i++){
    cin>>id;
    for(int j=0;j<2;j++){
      int befc=c;
      cin>>c;
      if(c>=0) t[c].p=id;
      if(j>0 && c>=0 && befc>=0)t[befc].r=c,t[c].r=befc;
      else if(j==0)t[id].l=c;
      if(t[id].l<0 && j>0)t[id].l=c;
    }
  }

  for(int i=0;i<n;i++){
    cout<<"node "<<i<<": parent = "<<t[i].p<<", sibling = "<<sibling(i)<<", degree = "<<degree(i) <<", depth = ";
    cout<<dep(i)<<", ";
    cout<<"height = "<<height(i)<<", ";
    if(t[i].l>=0 && t[i].p>=0) cout<<"internal node";
    else if(t[i].p==-1) cout<<"root";
    else cout<<"leaf";
    cout<<endl;
  }


  return 0;
}