/* 
* Rooted tree
* output 1)node_number, 2)parent_number, 3)depth, 4)kind_of_node, 5)child_list
*/

/* inclution */
#include <stdio.h>

/* Definition */
#define MAX 100000
#define NIL -1

/* Prototype */
void printTree(int);
void getDepth(int, int);

/* Global Variables */
struct Node {
  int parent, left, right;
};
struct Node T[MAX]; //array for tree
int n,D[MAX]; //array for depth

/* main */
int main(){
  int i,j,node,degree,child,left,right;
  
  /* input the number of A[] */
  scanf("%d",&n);
  
  /* initialize array */
  for(i=0;i<n;i++) { //??¨??????NIL??§?????????
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
  
  /* input datas */
  for(i=0;i<n;i++){
    scanf("%d%d",&node, &degree);
    for(j=0;j<degree;j++){ //??¨?????¨?????¨????§????
      scanf("%d", &child);
      if(j==0) {
        T[node].left = child; //?????????left??????
      }else {
        T[left].right = child; //left?????????right????????????
      }
      left = child;
      T[child].parent = node; //???????¨????
    }
  }

  /* input Depth datas */
  for(i=0;i<n;i++) {
    if(T[i].parent == NIL) {
      right = i;
    }
  }
  getDepth(right, 0);
    
  /* print out */
  for(i=0;i<n;i++) {
    printTree(i); //print????????????
  }

  return 0;
}

/* Print ???????????? */
void printTree(int u) { //u???node??????
  int i, c;
  /* each elements */
  printf("node %d: ",u); //node
  printf("parent = %d, ", T[u].parent);
  printf("depth = %d, ", D[u]);
  
  /* kind of node */
  if(T[u].parent == NIL) {
    printf("root, ");
  }else if(T[u].left == NIL) {
    printf("leaf, ");
  }else {
    printf("internal node, ");
  }
  
  /* print child list */
  printf("[");
  c = T[u].left; //??????????????????
  while(c!=NIL){ //?????????????????¨????????????????????????????????????
    if(c==T[u].left){ //???????????????????????´
      printf("%d",c);
    }else {
      printf(", %d", c); 
    }
    c = T[c].right; //?????????????????????
  }
  printf("]\n");
}


void getDepth(int u, int d){ //u: node??????
  D[u] = d;
  if(T[u].right!=NIL) { //????????????????¢????
    getDepth(T[u].right, d);
  }
  if(T[u].left!=NIL) { //???????¢????
    getDepth(T[u].left, d+1); //?????????????????¨????????¨???,depth??????????¢????????????????????????????
  }
}