#include<stdio.h>

typedef struct{
  int parent;
  int left;
  int right;
} DATA;

#define MAX 1000000
#define NIL -1

DATA array[MAX];

int main(){
  int i;
  int id;
  int j;
  int n;
  int k;
  int count[100001];
  int hukasa = 0;
  int num;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    array[i].parent = NIL;
    array[i].left = NIL;
    array[i].right = NIL;
  }
  for(i = 0;i < n;i++){
    scanf("%d%d",&id,&k);
    for(j = 0;j < k;j++){
      scanf("%d",&count[j]);
      if(j == 0){
        array[count[0]].parent = id;
        array[id].left = count[0];
      }
      else{
        array[count[j]].parent = id;
        array[count[j - 1]].right = count[j];
      }
    }
  }

  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, ",i,array[i].parent);
    num = i;
    while(array[num].parent != NIL){
      hukasa++;
      num = array[num].parent;
    }
    printf("depth = %d,",hukasa);
    hukasa = 0;
    if(array[i].parent == NIL && array[i].left == NIL){
      printf("root, []\n");
    }
    else if(array[i].parent == NIL && array[i].left != NIL){
      printf(" root, [%d",array[i].left);
      for(j = array[array[i].left].right;j != NIL;j = array[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    else if(array[i].left != NIL){
      printf(" internal node, [%d",array[i].left);
      for(j = array[array[i].left].right;j != NIL;j = array[j].right){
        printf(", %d",j);
      }
      printf("]\n");
    }
    else{
      printf(" leaf, []\n");
    }
  }
  return 0;
}

