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

struct Node{ int p, l, r, lef;};
struct Node T[MAX]; 

void print(int u){

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

int main(){
  int i, j, temp1, temp2, temp3, temp4, n;
  
  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", &temp2, &temp1);
    for ( j = 0; j < temp1; j++ ){
      scanf("%d", &temp3);
      T[temp3].p = temp2;

      if(j == 0){
	T[temp2].l = temp3;
      }else if(j > 0){
	T[temp4].r = temp3;
      }
      temp4 = temp3;
    }
  }  
  
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}