#include<stdio.h>
#define MAX 1000000
#define NO -1

typedef struct Node{
  int p;
  int l;
  int r;
}S;
S tree[MAX];

int Depth(int);
void Out(int);

int main(){
  int a,b,i,j,l,m,n;

  scanf("%d",&n);
  for(i = 0  ; i < n ; i++){
    tree[i].p=tree[i].r=tree[i].l=NO;
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&a,&b);
    for(j = 0 ; j < b ; j++){
      scanf("%d",&m);
      if(j == 0){
        tree[a].l = m;
      }
      else {
        tree[l].r = m;
      }
      l = m;
      tree[m].p = a;
    }
  }
  for(i = 0 ; i < n ; i++){
    Out(i);
  }

  return 0;
}

int Depth(int x){
  int d=0;

  while(tree[x].p != NO){
    x = tree[x].p;
    d++;
  }

  return d;
}

void Out(int y){
  int i,j;

  printf("node %d: ",y);
  printf("parent = %d, ",tree[y].p);
  printf("depth = %d, ",Depth(y));

  if(tree[y].p == NO){
    printf("root, ");
  }
  else if(tree[y].l==NO){
    printf("leaf, ");
  }
  else{
    printf("internal node, ");
  }
  printf("[");

  for(i = 0 , j = tree[y].l ; j != NO ; i++ , j = tree[j].r){
    if(i){
      printf(", ");
    }
    printf("%d",j);
  }
  printf("]\n");
}

