#include <stdio.h>
#include <stdlib.h>

#define NIL -1

typedef struct{ 
  int parent; // ???
  int left; // ???????????????
  int right;// ????????????
  int k; // ???????????°
}Node;

Node T[100000];

int calculateDepth(int);
void PrintType(int);
void PrintDegree(int);

int main(){
  int n, i, j, v, v2;
  int id, k;


  scanf("%d", &n);

  //T = (Node *)malloc(sizeof(Node) * n);

  for(i=0; i<n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }

  for(i=0; i<n; i++){
    scanf("%d%d", &id, &k);
    T[id].k = k;
     for(j=0; j<T[id].k; j++){
       scanf("%d", &v);
      if(j == 0){
	T[id].left = v;
	T[v].parent = id;
	v2 = v;
      }else{
	T[v].parent = id;
	T[v2].right = v;
	v2 = v; 
      }
     }
  }
  
  for(i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, calculateDepth(i));
    PrintType(i);
    PrintDegree(i);
  }

  return 0;
}

int calculateDepth(int n){
  int i, parent;

  if(T[n].parent == -1) return 0;

  parent = T[n].parent;

  for(i=1; T[parent].parent != -1; i++){
    parent = T[parent].parent;
  }
  return i;

}

void PrintType(int n){
  if(T[n].parent == -1) printf("root, ");
  else if(T[n].left == -1) printf("leaf, ");
  else printf("internal node, ");
}

void PrintDegree(int n){
  int i, right;

  printf("[");

  for(i=0; i<T[n].k; i++){

    if(T[n].k == 1){
      printf("%d",T[n].left);
      break;
    }

    if(i == 0){
      printf("%d", T[n].left);
      right = T[T[n].left].right;
    }else if( i == T[n].k - 1){
      printf("%d", right);
      break;
    }else{
      printf("%d", right);
      right = T[right].right;
    }
    printf(", ");
  }

  printf("]\n");

}