
#include <stdio.h>

void depth(int,int);
void height(int,int);

int d[25],s[25],c[25][2],p[25],h[25],hh;

int main()
{
  int n,i,j,id,type[25],left,right,hig=0;

  scanf("%d",&n);
  for(j=0;j<n;j++){
    c[j][0]=-1;
  }
  p[0]=-1;
  s[0]=-1;

  for(j=0;j<n;j++){
    scanf("%d",&id);
    scanf("%d %d",&left,&right);

    c[id][0]=left;
    c[id][1]=right;

    s[left]=right;
    s[right]=left;

    p[left] = id;
    p[right] = id;
  }

  /*type*/
  for(j=0;j<n;j++){
    if(p[j]==-1) {
      type[j] = 0;
    }
    else if(c[j][0]==-1) type[j] = 1;
    else type[j] = 2;
  }

  depth(0,0);
  
  for(j=0;j<n;j++){
    hh=0;
    height(j,0);
    h[j]=hh;
  }

  /* ??¨??? */
  for(j=0;j<n;j++){
    printf("node %d: parent = %d, sibling = %d, ",j,p[j],s[j]);

    printf("degree = ");
    if(type[j]==1) printf("0, ");
    else printf("2, ");

    printf("depth = %d, ",d[j]);
    printf("height = %d, ",h[j]);

    if(type[j]==0) printf("root\n");
    else if(type[j]==1) printf("leaf\n");
    else printf("internal node\n");
  }

  return 0;
}

void depth(int id,int dep){
  d[0]=0;
  if(id!=0){
    if(s[id]==-1) return;
  }

  dep++;
 
  d[c[id][0]]=dep;
  d[c[id][1]]=dep;

  depth(c[id][0],dep);
  depth(c[id][1],dep);
}

void height(int id,int hig){
  d[0]=0;
  if(id!=0){
    if(s[id]==-1) return;
  }

  if(hh<=hig) hh=hig;
  hig++;

  height(c[id][0],hig);
  height(c[id][1],hig);
}