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

typedef struct node{
  int p;
  int left;
  int right;
}Node;


int main()
{
  int n,i,j,id,k,c,r,depth;
  Node *tree;

  scanf("%d",&n);

  tree = (Node *)malloc(sizeof(Node)*n);

  for(i = 0; i < n; i++){
    tree[i].p = -1;
    tree[i].left = -1;
    tree[i].right = -1;
  }

  for(i = 0; i < n; i++){
    scanf("%d %d",&id,&k);

    for(j = 0; j < k; j++){
      scanf("%d",&c);
      tree[c].p = id;

      if(j == 0){
	tree[id].left = c;
      }
      else if(j > 0){
	tree[r].right = c;
      }
      r = c;
    }
  }

  for(j = 0; j < n; j++){
    depth = 0;
    i = tree[j].p;

    while(i != -1){
      i = tree[i].p;
      depth++;
    }

    if(depth == 0){
      printf("node %d: parent = %d, depth = %d, root, ",j,tree[j].p,depth);
    }
    else if(tree[j].left == -1){
      printf("node %d: parent = %d, depth = %d, leaf, ",j,tree[j].p,depth);
    }
    else {
      printf("node %d: parent = %d, depth = %d, internal node, ",j,tree[j].p,depth);
    }

    i = tree[j].left;
    printf("[");
    if(i != -1){
      printf("%d",i);
    }
    while(i != -1){
      i = tree[i].right;
      if(i != -1){
	printf(", %d",i);
      }
    }
    printf("]\n");
  }
  return 0;
}