#include <stdio.h>
#include <stdlib.h>
struct Node{
  int depth;
  int p;//parent
  int l,r; 
} ;
struct Node *tree;
int main(){
  
  int i,j,n,d,id,c,a,x,y;
  
  scanf("%d",&n);
  tree = malloc(sizeof(struct Node)*n);
  
  for(i=0;i<n;i++){
    tree[i].p = -1;
    tree[i].l = -1;
    tree[i].r = -1;
    scanf("%d%d",&id,&d);
    
    for(j=0;j<d;j++){
      printf("d = %d\n",d);
      scanf("%d",&c);
      if(j==0){
	//printf("fuck1\n");
	tree[id].l = c;
	tree[c].p = id;
	a = c;
      }else{
	tree[a].r = c;
	tree[c].p = id;
	//printf("fuck2 %d\n",tree[c].p);
	a = c;
      }
    }
  }
  
  for(i=0;i<n;i++){
    x=0;
    y=i;
    while(tree[y].p>-1){
      y = tree[y].p;
      x++;
      //printf("p = %d\n",tree[y].p);//
    }
    tree[i].depth = x; 
  }

  
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].p,tree[i].depth);
    if(tree[i].p == -1)printf("root, ");
    else if(tree[i].l == -1)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    if(tree[i].l != -1){
      printf("%d",tree[i].l);
      a = tree[i].l;
      while(1){
	if(tree[i].r == -1)break;
	printf(", %d",tree[a].r);
	a = tree[a].r;
      }
    }
    printf("]\n"); 
  }
  

  free(tree);
  
  
  return 0;
  }

