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

#define NMAX 100000

struct treenode{
  int id;
  int p;
  int d;
  char type[15];
  int cnum;
  int *c;
};

int main (void)
{
  int n,i,j,k;
  struct treenode node[NMAX];

  //入力
  scanf ("%d",&n);

  for (i = 0 ; i < n ; i++){
    scanf ("%d %d",&node[i].id,&node[i].cnum);
    node[i].c = malloc(sizeof(int) * node[i].cnum);

    for (j = 0 ; j < node[i].cnum ; j++){
      scanf ("%d",&node[i].c[j]);
    }
  }

  //情報の処理 p,d,type
  node[0].p = -1;
  node[0].d = 0;
  strcpy(node[0].type,"root");

  for (i = 1 ; i < n ; i++){
    for (j = 0 ; j < i ; j++){
      for (k = 0 ; k < node[j].cnum ; k++){
	if (node[i].id == node[j].c[k])
	  node[i].p = node[j].id;
      }
    }

    node[i].d = node[node[i].p].d + 1;

    if (node[i].cnum != 0)
      strcpy(node[i].type,"internal node");
    else
      strcpy(node[i].type,"leaf");
    
  }

  //出力
  for (i = 0 ; i < n ; i++){
    printf ("node %d: parent = %d, depth = %d, %s, [",node[i].id,node[i].p,node[i].d,node[i].type);

    if (node[i].cnum == 0)
      printf ("]\n");

    else{
      for (j = 0 ; j < node[i].cnum ; j++){
	printf ("%d",node[i].c[j]);
	if (j < node[i].cnum - 1)
	  printf (", ");
	else
	  printf ("]\n");
      }
    }
  }

  //解放
  for (i = 0 ; i < n ; i++)
    free(node[i].c);

  return 0;
}