#include<stdio.h>
#define MAX 100000

struct Node{
  int p,r,l;
};
struct Node T[MAX];

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

