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

int FindDepth(int);
void output(int);
int FindHeight(int);
typedef struct{
  int parent;
  int left;
  int right;
}vertex;

vertex V[25];
int D[25],F[25],ver[25];
int n;
int FHd=0;
main()
{
  int i,maesoe;
  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      V[i].parent = V[i].left = V[i].right = NIL;
    }

  for(i=0;i<n;i++)
    {
      scanf("%d",&ver[i]);/*ver[i]????????????????????\???*/
      if(ver[i] == 0)V[ver[i]].parent==NIL;/*root?????´???*/
      else
	{
	  V[ver[i]].parent = maesoe;
	}
      scanf("%d",&V[ver[i]].left);/*root???parent??\???????????§???-1?????\??£??????*/
      scanf("%d",&V[ver[i]].right);
      maesoe = ver[i];
    }/*??\?????????*/

  for(i=0;i<n;i++)
    {
      D[i] = FindDepth(i);
    }

  for(i=0;i<n;i++)
    {
      F[i] = FindHeight(i);
    }
  for(i=0;i<n;i++)
    {
      output(i);
    }




}

int FindDepth(int i)
{
  int d = 0,u = 0;
  while(1){

    if(V[ver[i]].parent == NIL)break;
    d++;
    i = V[ver[i]].parent;
  }
  return d;
}

int FindHeight(int i)
{
  
    if(V[ver[i]].left == NIL && V[ver[i]].right == NIL)return FHd;
    FHd++;
    FindHeight(V[ver[i]].left);
    FindHeight(V[ver[i]].right);
  
}




void output(int p)
{
  printf("node %d: parent = %d, degree = ",ver[p],V[ver[p]].parent);
  if(V[ver[p]].left ==NIL && V[ver[p]].right ==NIL)printf("0, ");
  else if(V[ver[p]].left == NIL || V[ver[p]].right == NIL)printf("1, ");
  else printf("2, ");

  printf("depth = %d, height = %d, ",D[ver[p]],F[ver[p]]);

  if(V[ver[p]].left == NIL && V[ver[p]].parent != NIL)printf("leaf\n");
  else if(V[ver[p]].parent == NIL)printf("root\n");
  else printf("internal node\n");
}