#include<stdio.h>
#define MAX 100005
#define NIL -1

/*
 p: parent
 l: left-child
 r: right sibling
 */
struct Node{
  int p, l, r;
};
struct Node T[MAX]; // Tree
int n;
int depth(int u){
  int d = 0, i;
  for(i=u; T[i].p!=NIL; i=T[i].p, d++);
  return d;
}
void print(int u){

  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,depth(u));
   
  if( T[u].p == NIL) printf("root, [");
  else if(T[u].l == NIL) printf("leaf, [");
  else printf("internal node, [");
   
  if( T[u].l != NIL){
    while(1){
      if(T[T[u].l].r == NIL){
	printf("%d",T[u].l);
	break;
      }
      else {
	printf("%d, ",T[u].l);
	T[u].l = T[T[u].l].r;
      }
    }
  }
  
  printf("]\n");
}

main(){
  int i, j, d, v, c, l,tmp;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = NIL;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      
      if(j == 0){
	T[v].l = c;
	T[c].p = v;
	tmp = c;
      }
      else{
	T[tmp].r = c;
	T[c].p = v;
	tmp = c;
      }
    }
  }
  
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}