#include<stdio.h>
#define N 100000
typedef struct {
  int parent,left,right;
}jeep;
jeep A[N];
int main(){
  int total,i,j,a,b,son,di,count,c,d;
  scanf("%d",&total);
  for(i=0;i<total;i++){
    A[i].parent=-1;
    A[i].left=-1;
    A[i].right=-1;
  }
  for(i=0;i<total;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      if(j==0){
        scanf("%d",&son);
        A[a].left=son;
        A[son].parent=a;
      }
      else{
        scanf("%d",&son);
        A[di].right=son;
        A[son].parent=a;
      }
      di=son;
    }
  }
  for(i=0;i<total;i++){
    printf("node %d: ",i);
    printf("parent = %d, ",A[i].parent);
    c=i;
    count=0;
    while(1){
      if(A[c].parent==-1)break;
      c=A[c].parent;
      count++;
    }
    printf("depth = %d, ",count);
    if(A[i].parent==-1){
      printf("root, ");
    }
    else if(A[i].left==-1&&A[i].parent!=-1){
      printf("leaf, ");}
    else{
      printf("internal node, ");
    }
    printf("[");
    if(A[i].left!=-1){
      printf("%d",A[i].left);
      d=A[i].left;
      while(1){
        if(A[d].right==-1)break;
        printf(", %d",A[d].right);
        d=A[d].right;
      }
    }
    printf("]\n");
  }
  return 0;
}
