#include<stdio.h>
#include <stdlib.h>
typedef struct{
  int id,parent,depth,type; //type:1,root,2,internal node, 3,leaf
  int num; //nimber of data
  int *data;
}treenode;
int main(){
  int n,d,i,j,k,id;
  char ttype[3][20] = {"root","internal node","leaf"};
  treenode *a;
  scanf("%d",&n);
  a = (treenode *)malloc(sizeof(treenode)*n);
  for(i =0;i < n;i++){
    scanf("%d %d",&id,&j);
    a[i].id = id;
    a[i].num = j;
    a[i].data = malloc(sizeof(int)*j);
    if(i == 0){
      a[i].depth = 0;
      a[i].parent = -1;
    }
    for(k =0;k <j;k++){
       scanf("%d",&a[i].data[k]);
         a[a[i].data[k]].parent = a[i].id;
         a[a[i].data[k]].depth = a[i].depth + 1;
     }
    if(i == 0) a[i].type = 1;
    else if(j != 0) a[i].type = 2;
    else a[i].type = 3;
  }
  for(i =0;i < n;i++){
    printf("node %d: parent = %d, depth = %d, %s, [",a[i].id,a[i].parent,a[i].depth,ttype[a[i].type - 1]);
    if(a[i].num != 0){
      for(j =0;j < a[i].num - 1;j++) printf("%d, ",a[i].data[j]);
      printf("%d]\n",a[i].data[j]);
    }else printf("]\n");
  }
  return 0;
}

