#include<stdio.h>

typedef struct tree{
  int p,l,r;
}t;
t T[100000];
 
int main(){
  int n,i,j,k,id,c,a,b;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      T[c].p=id;
      if(j==0)
    T[id].l=c;
      else
    T[a].r=c;
      a=c;
    }
  }
  for(i=0;i<n;i++){
    id=0;
    k=0;
    a=T[i].p;
    b=T[i].l;
    while(a!=-1){
      k++,a=T[a].p;
    }
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,k);
    if(T[i].p==-1)
      printf("root, [");
    else if(T[i].l!=-1)
      printf("internal node, [");
    else
      printf("leaf, [");
    while(b!=-1){
      if(id==0){
    printf("%d",T[i].l);
    id=1;
      }
      else
    printf(", %d",b);
      b=T[b].r;
    }
    printf("]\n");
  }
  return 0;
}