#include<stdio.h>
#define N 100000
#define NIL -1
 
struct Node{
  int p, l, r;
};
 
struct Node T[N];
int n, H=0, D[N];
 
int getDepth(int);
void print(int);
 
int main(){
  int i, j, d, v, c, l;   
  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;
      }
      else{
	T[l].r = c;
      }
      l = c;
      T[c].p = v;      
    }
  }
  for ( i = 0; i < n; i++ ){
    D[i] = getDepth(i);
    if ( D[i] > H ){
      H = D[i];
    }
  }  
  for ( i = 0; i < n; i++ ){
    print(i);
  }
  return 0;
}

int getDepth(int i){
  int a = 0;
  while(1){
    i = T[i].p;
    if ( i == NIL ) {
      break;
    }
    a++;
  }
  return a;
}

void print(int i){
  int j, c;
  printf("node %d: parent = %d, depth = %d, ",i,T[i].p,D[i]);
  if ( T[i].p == NIL ){
    printf("root, ");
  }
  else if ( T[i].l == NIL ){
    printf("leaf, ");
  }
  else{
    printf("internal node, ");
  }
  printf("[");
  for(j = 0, c = T[i].l; c != NIL; j++, c = T[c].r){
    if (j) {
      printf(", ");
    }
    printf("%d", c);
  }
  printf("]\n");
}