#include <stdio.h>
#define MAX 100000
#define N 2
typedef struct node{
  int pare;
  int left;
  int right;
  int hei;
  int deg;
  int sib;
}Node;

Node a[MAX];
int depth[MAX];
void searchdep(int,int);
int main(){
  int n,i,num,sum,j,tmp,k,count;
  scanf("%d",&n);
  for(i = 0 ;i<n ;i++){
    a[i].left = -1;
    a[i].right =-1;
    a[i].pare = -1;
  }

  
  for(i = 0 ;i<n ;i++){
    scanf("%d",&num);
    count=0;
    for(j = 0;j<N;j++){
      scanf("%d",&tmp);
      if(tmp ==-1){
	continue;
      }
      if(j ==0) {
	a[num].left = tmp;
	count++;
      }
      else {a[k].right= tmp;
	count++;
      }
      	k=tmp;
	a[k].pare = num;
      }
     a[i].deg = count;
    }

  for(i =0;i<n;i++){
    if(a[i].pare == -1){
      searchdep(i,0);
    }
  }
  for(i = 0 ;i<n ;i++){
    if(a[i].right != -1){
      a[i].sib = a[i].right;
    }
    else if(a[i].pare ==-1){
      a[i].sib = -1;
    }
    else if(a[i].right ==-1){
      a[i].sib = a[a[i].pare].left;
    }
  }
  for(i = 0;i<n;i++){
    count=0;
    if(a[i].pare ==-1){
      a[i].hei = 3;
    }
    else if(a[i].left ==-1)
      a[i].hei = 0;
    else if(a[i].left !=-1){
      j=i;
      while(a[j].left !=-1){
	j = a[j].left;
	count++;
      }
      a[i].hei = count;
    }
  }
  for(i =0 ;i<n;i++){
    if(a[i].pare ==-1){
      printf("node %d: parent = %d, sibling = %d, degree = %d,  depth = %d, height = %d, root \n",i,a[i].pare,a[i].sib,a[i].deg,depth[i],a[i].hei);
    }
    else if(a[i].left !=-1 && a[i].pare != -1){
      printf("node %d: parent = %d, sibling = %d, degree = %d,  depth = %d, height = %d, internal node \n",i,a[i].pare,a[i].sib,a[i].deg,depth[i],a[i].hei);
    }
    else if(a[i].left ==-1){
      printf("node %d: parent = %d, sibling = %d, degree = %d,  depth = %d, height = %d, leaf \n",i,a[i].pare,a[i].sib,a[i].deg,depth[i],a[i].hei);
    }
  }
  return 0;
}
      
void searchdep(int c ,int b){
  depth[c] = b;
  if(a[c].right !=-1){
    searchdep(a[c].right,b);
  }
  if(a[c].left != -1){
    searchdep(a[c].left,b+1);
  }
}

