//2020.1.6
//s1270188 xxxmk2
//alds1_07a

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

//struct
typedef struct {
  int p, l, r;
}node;

//prototype
int depth(int);

//global
node *data;

int main(){
  int i, j, a, b, c, d, num;

  //input
  scanf("%d",&num);
  data=(node *)malloc(sizeof(node)*num);
  for(i=0;i<num;i++) data[i].p=data[i].l=data[i].r=-1;
  
  for(i=0;i<num;i++){
    scanf("%d %d",&a,&b);

    for(j=0;j<b;j++){
      scanf("%d",&c);
      if(j==0) data[a].l=c;
      else data[d].r=c;
      d=c;
      data[c].p=a;
    }  
  }

  //output
  for(i=0;i<num;i++){
    printf("node %d: parent = %d, depth = %d, ",i,data[i].p,depth(i));

    if(data[i].p==-1) printf("root, [");
    else if(data[i].l==-1) printf("leaf, [");
    else printf("internal node, [");

    for(j=data[i].l;j!=-1;j=data[j].r){
      if(data[j].r==-1) printf("%d",j);
      else printf("%d, ",j);
    }
    printf("]\n");
    
  }

  free(data);
  return 0;
}

int depth(int n){
  int depth=0;

  for(;data[n].p!=-1;n=data[n].p) depth++;

  return depth;
}

