#include<stdio.h>
#define N 100

struct Node{
  int parent;
  int left;
  int right;
  int id;
  int k;
  int c[N];
};
struct Node T[N];

int depthfunc(struct Node);
int typefunc(struct Node);
int d;

int main(){
  int n,id,i,j,k,dep[N],type[N];

  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d %d",&T[i].id,&T[i].k);
    for(j=0 ; j<T[i].k ; j++){
      scanf("%d ",&T[i].c[j]);
    }
  }
  T[0].parent=-1;
  for(k=0;k<n;k++){
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<T[i].k ; j++){
      if(T[k].id==T[i].c[j]) T[k].parent=T[i].id;
    }
  }
  }
  for(i=0 ; i<n ; i++){
    d=0;
    dep[i]=depthfunc(T[i]);
    type[i]=typefunc(T[i]);
  }
  for(i=0 ; i<n ; i++){
    if(type[i]==0)
      printf("node %d: parent = %d, depth = %d, root, [",T[i].id, T[i].parent, dep[i]);
    else if(type[i]==1)
      printf("node %d: parent = %d, depth = %d, leaf, [",T[i].id, T[i].parent, dep[i]);
    if(type[i]==2)
      printf("node %d: parent = %d, depth = %d, internal node, [",T[i].id, T[i].parent, dep[i]);
    for(j=0 ; j<T[i].k ; j++){
      if(j>=1)printf(", ");
      printf("%d",T[i].c[j]);
    }
    printf("]\n");
  }
  
  return 0;
  
}

int depthfunc(struct Node id2){
  if(id2.parent == -1)return d;
  else{
    d++;
    depthfunc(T[id2.parent]);
  }
}

int typefunc(struct Node id3){
  if(id3.parent==-1)return 0;
  else if((id3.left==-1)&&(id3.right==-1))return 1;
  else return 2;
}