#include<stdio.h>

struct Node{
  int depth;
  int parent;
  int r;
  int k;
  int a[100];
};

int main(){
  int i,j,l,id;
  struct Node c[100000];

  scanf("%d",&l);
  for(i = 0; i < l; i++){
    scanf("%d %d",&id,&c[id].k);
    c[id].r = 0;
    c[id].parent = -1;
    c[id].depth = 0;
    if(c[id].k == 0) c[id].r = 2; 
    for(j = 0; j < c[id].k; j++){
      scanf("%d",&c[id].a[j]);
      c[c[id].a[j]].r = 1;
      c[c[id].a[j]].depth++;
      c[c[id].a[j]].parent = id;
    }
  }

  for(i = 0; i < l; i++){
    printf("node %d: parent = %d, depth = %d, ",i,c[i].parent,c[i].depth);
    if(c[i].r == 0) printf("root, [");
    else if(c[i].r == 1) printf("internal node, [");
    else printf("leaf, [");

    if(c[i].r != 2){
      for(j = 0; j < c[i].k - 1; j++)
	printf("%d,",c[i].a[j]);
      printf(" %d",c[i].a[c[i].k - 1]);
    }
    printf("];");
  }
  
  
  return 0;
}


