#include<stdio.h>
#define NIL -1
#define MAX 10000

 struct node{
           int parent;
           int left;
           int right;
           };

 struct node T[MAX];
 int H[MAX];

 int sibl(int u){
          if(T[u].parent==NIL)return NIL;
          int p=T[u].parent;
          if(T[p].left==u)return T[p].right;
          else T[p].left;
          }

 int depth(int u){
          int d=0;
          while(T[u].parent!=NIL){
                  int p=T[u].parent;
                  d++;
                  }
          return d;
          }

 int height(int u){
          int n1=0,n2=0;
          if(T[u].left==0)return 0;
          if(T[u].left!=0)n1=height(T[u].left)+1;
          if(T[u].right!=0)n2=height(T[u].right)+1;
          if(n1>n2)return n1;
          else return n2;
          }
  
 void print(int i){
         
         printf("node %d: parent = %d, ",i,T[i].parent);
         printf("sibling = %d, ",sibl(i));
         (T[i].left!=NIL)?printf("degree = 2, "):printf("degree = 0, ");
         printf("depth = %d, ",depth(i));
         printf("height = %d, ",height(i));
         if(T[i].parent==NIL)printf("root\n");
         else if(T[i].left==NIL)printf("leaf\n");
         else printf("internal node\n");
         }
      }


 int main(){
         int i,n,k,v,l,r;
         scanf("%d",&n);
         for(i=0;i<n;i++){T[i].parent=T[i].left=T[i].right=NIL;}
         for(i=0;i<n;i++){
                   scanf("%d%d%d",&k,&l,&r);
                   T[k].left=l;
                   T[k].right=r;
                   if(l!=NIL)T[l].parent=k;
                   if(r!=NIL)T[r].parent=k;
                   
                   }
         
         for(i=0;i<n;i++){print(i)};
         return 0;
         }
