#include<stdio.h>
#define N 100000

typedef struct{
  int parent;
  int left;
  int right;
  int depth;
}node;

node T[N];

int main(){
  int n, i, j;
  int id, k, c, p, q;

  scanf("%d\n",&n);
  for(i = 0 ; i < n ; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
    T[i].depth = 0;
  }

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