#include <stdio.h>
#define MAX 100000

struct Node{
  int parent,right,left;
};

struct Node T[MAX];

int main(){
  int n,i,j,id,k,c[MAX],a,d[MAX];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent = -1;
      T[i].right = T[i].left = -1;
      d[i] = 0;
  }
  
  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]].parent = id;
        if(j == 0){
          T[id].left = c[j];
        }
        else T[c[j-1]].right = c[j];
      
      }
    }
  }
  for(i=0;i<n;i++){
    j = i;
    while(1){
      if(T[j].parent == -1)break;
      j = T[j].parent;
      d[i]++;
    }
  }
 
  for(i=0;i<n;i++){
    printf("node %d:",i);
    printf(" parent = %d,",T[i].parent);
    printf(" depth = %d," ,d[i]);
    if(T[i].parent == -1){
      printf(" root, [");
    }
    else if(T[i].left != -1){
      printf(" internal node, [");
    }
    else printf(" leaf, [");
    id = T[i].left;
    j=0;
    while(1){
      if(id == -1) break;
      if(j != 0) printf(", ");
      printf("%d",id);
      id = T[id].right;
      j++;
    }
    printf("]\n");
  }

  return 0;
  
}


