/*ツリー構造*/
#include <stdio.h>
#include <stdlib.h>
#define N 100001

typedef struct node{
  int no;
  int depth;
  int nch;
  int *c;
  int pa;
} Node;

int main(){
  Node a[N];
  int n, i, j, num, ch, count=0;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    a[i].pa = -1;
    a[i].depth = -2;
  }
  
  for(i=0; i<n; i++){
    scanf("%d%d", &num, &ch);
    if (ch != 0) count++;
    a[num].no = num;
    a[num].nch = ch;
    a[num].c = (int *)malloc(sizeof(int) * ch);
    for (j=0; j<ch; j++){
      scanf("%d", &a[num].c[j]);
      a[a[num].c[j]].pa = a[num].no;
    }
  }

  
  for (i=0; i<n; i++){
    if(a[i].pa == -1) a[i].depth =0;
  }
  
  j=0;
  while(1){
    for (i=0; i<n; i++){
      if(a[i].pa == a[a[i].pa].no)
	a[i].depth = a[a[i].pa].depth+1;
    }
    j++;
    if (count == j) break;
  }
  
  for (i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d, "
	   , a[i].no, a[i].pa, a[i].depth);
    
    if (a[i].pa == -1){
      printf("root, [");
      for (j=0; j<a[i].nch; j++){
	if (j == a[i].nch-1)
	  printf("%d", a[i].c[j]);
	else
	  printf("%d, ",a[i].c[j]);
      }
      printf("]\n");
    }
    
    else if (a[i].nch != 0){
      printf("internal node, [");
      for (j=0; j<a[i].nch; j++){
	if (j == a[i].nch-1)
	  printf("%d", a[i].c[j]);
	else
	  printf("%d, ",a[i].c[j]);
      }
      printf("]\n");
    }
    
    else printf("leaf, []\n");
  }

  for (i=0; i<n; i++)
   free(a[i].c);
  
  return 0;
}

