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

typedef struct pp{
  int id;
  int left;
  int right;
  int p;
} tree;
tree T[MAX];
int depth(int i){
  int count = 0;
  while(T[i].p != -1){
    ++count;
    i = T[i].p;
  }
  return count;

}
void printType(int i){
  if(T[i].p == NIL){
    printf("root");
    return;
  }else if(T[i].left == NIL){ 
    printf("leaf");
    return; 
  }else
    printf("internal node");
}
void printChild(int i){
  if(T[i].left == NIL){
    printf("[]");
    return;
  }else{
    printf("[");
    i = T[i].left;
    while(1){
      printf("%d", T[i].id);
      if(T[i].right == NIL){
        printf("]");
        break;
      }else{
        printf(", ");
      }
      i = T[i].right;
    }
    
  }
    
}
void print(int n){
  for(int i = 0; i < n; ++i){
    printf("node %d: parent = %d, ", T[i].id, T[i]. p);
    printf("depth = %d, ", depth(i));
    printType(i);
    printf(", ");
    printChild(i);
    printf("\n");
  }
}

int main(){
  int n;
  //接点の総数をもとめる
  char line[10000];
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d", &n);
  for(int i = 0; i < n; ++i){
    T[i].left = NIL;
    T[i].right = NIL;
    T[i].p = NIL;
    T[i].id = NIL;
    
  }
  //変数
  int count;
  char *str_ptr;
  int id;
  int numbers[100005];
  int c, l;

  for(int i = 0; i < n; ++i){
    //各接点の情報を受け取る
    fgets(line, sizeof(line), stdin);
    //idを取り出す
    str_ptr = strtok(line, " ");
    sscanf(str_ptr, "%d", &id);
    T[i].id = id;
    
    //接点の個数を取り出す
    str_ptr = strtok(NULL, " ");
    sscanf(str_ptr, "%d", &count);
    
    //
    for(int j = 0; j < count; ++j){
      str_ptr = strtok(NULL, " ");
      sscanf(str_ptr, "%d", &c);
      if(j == 0)
        T[id].left = c;
      else
        T[l].right = c;
      l = c;
      T[c].p = id;
    }
  }
  print(n);
  return 0;
}

