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

typedef struct {
  int par, left, right, dep;
}tree;

int depth(int,int);

tree t[100000];

int main()
{
  int i, j, n, id, noc, chi, left, root;

  scanf("%d",&n);
  for (i = 0; i < n; i++)
    t[i].par = t[i].left = t[i].right = NIL;
  for (i = 0; i < n; i++){
    scanf("%d%d",&id,&noc);
    for (j = 0; j < noc; j++){
      scanf("%d",&chi);
      if (j == 0)
	t[id].left = chi;
      else
	t[left].right = chi;
      left = chi;
      t[chi].par = id;
    }
  }
  for (i = 0; i < n; i++)
    if (t[i].par == NIL)
      root = i;
  depth(root,0);
  for (i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i,t[i].par,t[i].dep);
    if (i == root)
      printf("root, ");
    else if (t[i].left == NIL)
      printf("leaf, ");
    else
      printf("internal node, ");
    printf("[");
    chi = t[i].left;
    while (chi != NIL){
      if (chi != t[i].left)
	printf(", ");
      printf("%d",chi);
      chi = t[chi].right;
    }
    printf("]\n");
  }
  return 0;
}

int depth(int id, int d)
{
  t[id].dep = d;
  if (t[id].right != NIL)
    depth(t[id].right,d);
  if (t[id].left != NIL)
    depth(t[id].left,d+1);
}

