#include<stdio.h>

typedef struct {
  int id;
  int parent;        //親
  int child;         //子
  int sibling;       //兄弟
  int depth;         //深さ
  int degree;
  int height;
}Node;

Node node[100000]; 

main()
{
  int n, i, j, id, right, left, height=0;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++)
    {
      node[i].parent = -1;
      node[i].child = -1;
      node[i].sibling = -1;
      node[i].depth = 0;
      node[i].degree = 0;
      node[i].height = -1;
    }
  
  for(i=0; i<n; i++)
    {
      scanf("%d %d %d", &node[i].id, &left, &right);

      if(left != -1 && right != -1)
	{
	  node[i].degree = 2;

	  node[i].child = left;
	  node[left].sibling = right;
	  node[right].sibling = left;
	  node[left].parent = node[i].id;
	  node[right].parent = node[i].id;
	}



    }
 
  for(i=0; i<n; i++)
    {
      j = node[i].parent;
      
      while(1)
	{
	  if(j == -1)
	    {
	      break;
	    }
	  
	  j = node[j].parent;
	  node[i].depth++;
	  if(height < node[i].depth)
	    {
	      height = node[i].depth;
	    }
	}
    }

  for(i=0; i<n; i++)
    {      
      if(node[i].parent == -1)
	{
	  node[i].height = height;
	}
      else if(node[i].parent != -1)
	{
	  if(node[i].child == -1)
	    {
	      node[i].height = 0;

	      j = node[i].parent;	      
	      while(node[j].parent != -1)
		{
		  if(node[j].height == -1)
		    {
		      node[j].height = node[i].height + 1;
		      i = j;
		    }
		  j = node[j].parent;
		}
	    }
	}

    }


  for(i=0; i<n; i++)
    {
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", node[i].id, node[i].parent, node[i].sibling, node[i].degree, node[i].depth, node[i].height);
      
      if(node[i].parent == -1)
	{
	  printf("root\n");
	}
      else if(node[i].parent != -1)
	{
	  if(node[i].child != -1)
	    {
	      printf("internal node\n");
	    }
	  else
	    {
	      printf("leaf\n");
	    }
	}
      
    }

  return 0;
}