#include <stdio.h>
typedef struct{
  int poo,loo,roo;
}Node;

int deg(int);
int height(int);
int depth(int);
int sibling(int);
void print(int);
Node Ty[100000];

int main(){
  int i,su,n,loo,roo;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    Ty[i].poo = Ty[i].loo = Ty[i].roo = -1;
  }
 
  for(i=0;i<n;i++){
  
    scanf("%d%d%d",&su,&loo,&roo);
    Ty[su].loo = loo;
    Ty[su].roo = roo;
    Ty[loo].poo = su;
    Ty[roo].poo = su;
  }
  
  for(i=0;i<n;i++){
      print(i);
    }
  return 0;
}
 
int depth(int su)
{
  if(Ty[su].poo == -1) return 0;
  return 1+depth(Ty[su].poo);
}
 
int deg(int su)
{
  if(Ty[su].loo != -1 && Ty[su].roo != -1)  return 2;
  else if(Ty[su].loo != -1 || Ty[su].roo != -1) return 1;
  else return 0;
}

int height(int su)
{
  int left=0,right=0;
  
  if(su== -1) return 0;
  if (Ty[su].loo != -1) left = height(Ty[su].loo)+1;
  if(Ty[su].roo != -1) right = height(Ty[su].roo)+1;
  
  if(right < left) return left;
  else return right;
}

int sibling(int su)
{
  int parents = Ty[su].poo;
  
  if(Ty[su].poo == -1) return -1;
  else if(Ty[parents].loo != su) return Ty[parents].loo;
  else return Ty[parents].roo;
}
void print(int su)
{
  printf("node %d: parent = %d, sibling = %d, deg = %d, depth = %d, height = %d, ",su,Ty[su].poo,sibling(su),deg(su),depth(su),height(su));
  if(Ty[su].poo == -1) printf("root\n");
  else if(Ty[su].loo == -1 && Ty[su].roo == -1) printf("leaf\n");
  else printf("internal node\n");
}