#include<stdio.h>
#define M 100000
#define N -1

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

struct A B[M];

int  C[M];

int get(int z){
  
  int x=0;
  
  while(B[z].parent!=N){
    
    z=B[z].parent;
    
    x++;
  }
  return x;
}

void pr(int z){
  
  int i, c;
  
  printf("node %d: ", z);
  
  printf("parent = %d, ", B[z].parent);
  
  printf("depth = %d, ", C[z]);

  if ( B[z].parent == N) printf("root, [");
  
  else if ( B[z].left == N) printf("leaf, [");
  
  else printf("internal node, [");

  for(i = 0, c = B[z].left; c != N; i++, c = B[c].right){
    
    if (i) printf(", ");
    
    printf("%d", c);
  }
  printf("]\n");
}



int main(){
  
  int i,j,n,a,b,c,d,e;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    
    B[i].parent = B[i].left = B[i].right = N;
    
  }
  
  for ( i = 0; i < n; i++ ){
    
    scanf("%d%d",&b,&c);
    
    for ( j = 0; j < c; j++ ){
      
      scanf("%d", &e);
      
      if ( j == 0 ) B[b].left = e;
      
      else B[d].right = e;
      
      d = e;
      
      B[e].parent =b;
    }
  }
  
  a=0;
  
  for ( i = 0; i < n; i++ ){
    
    C[i] = get(i);
    
    if ( C[i] > a ){
      
      a = C[i];
    }
  }

  for ( i = 0; i < n; i++ ){
    
    pr(i);
    
  }
  
  return 0;
}



