#include <stdio.h>

#define MAX 100000
#define NIL -1

typedef struct{
  int parent;
  int leaf;
  int ree;
}tree;

tree T[MAX];

int main(){

  int n,i,j,node,zisu,child,left,count,Npare,Nani;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent=NIL;
    T[i].leaf=NIL;
    T[i].ree=NIL;
  }

  for(i=0;i<n;i++){

    scanf("%d%d",&node,&zisu);
    for(j=0;j<zisu;j++){
      if(j==0){
    scanf("%d",&child);
    T[node].leaf=child;
    T[child].parent=node;
    }
      else {
    scanf("%d",&child);
    T[left].ree=child;
    T[child].parent=node;
}
      left=child;

    }
  }

  for(i=0;i<n;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].parent);
    count=0;
    Npare=i;
    while(1){
      if(T[Npare].parent==NIL) break;
      Npare=T[Npare].parent;
      count++;
    }
    printf("depth = %d, ",count);
    if(T[i].parent == NIL){
      printf("root, ");
    }
    else if(T[i].leaf == NIL && T[i].parent != NIL){
      printf("leaf, ");
    }
    else{
      printf("internal node, ");
    }
    printf("[");
    if(T[i].leaf !=-1){
      printf("%d",T[i].leaf);
      Nani= T[i].leaf;
      while(1){
    if(T[Nani].ree == -1)break;
    printf(", %d",T[Nani].ree);
    Nani=T[Nani].ree;
      }
    }
    printf("]\n");
  }

  return 0;
}