#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*構造体の宣言*/
typedef struct Tree
{
  int parent;
  int l;
  int right;
}tree;

tree T[100000];
int n;

/*PrintChild関数*/
void PrintChild(int i)
{
  int brother;
  
  if(T[i].l  != -1){
    printf("%d", T[i].l);
    brother = T[i].l;
    while(1){
      if(T[brother].right == -1)break;
      printf(", %d", T[brother].right);
      brother = T[brother].right;
    }
  }
}

/*judge関数*/
void judge(int i)
{
  if(T[i].l == -1 && T[i].parent != -1)
    printf("leaf,");
  else if(T[i].parent == -1)
    printf("root,");
  //
  else
    printf("internal node,");
}

/*depth関数*/
int depth(int i)
{
  int count = 0, parent_i;
  parent_i = i;
  while(1){
    if(T[parent_i].parent == -1)
      break;
    parent_i = T[parent_i].parent;
    count++;
  }
  return count;
}

/*ここからがmain関数*/
int main()
{
  int count, j, node, degree, child, left;

  scanf("%d",&n);

  for(count = 0; count < n; count++){
    T[count].parent = -1;
    T[count].l = -1;
    T[count].right = -1;
  }
  for(count = 0; count < n; count++){
    scanf("%d%d", &node, &degree);
    for(j = 0; j < degree; j++){
      scanf("%d", &child);
      if(j == 0){
	T[node].l = child;
	T[child].parent = node;
      }   
      else{
	T[left].right = child;
	T[child].parent = node;
      }
      left = child;
    }
  }
  for(count = 0; count < n; count++){
    printf("node %d: parent = %d, depth = %d, ", count, T[count].parent, depth(count));
    judge(count);

    printf(" [");
    PrintChild(count);
    printf("]\n");    
  }

  return 0;
}



