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

int c[100000][20];

int main(){
  int n,i,j,id;
  int *k,*p,*d;

  for(i = 0;i < 100000;i++){
    for(j = 0;j < 20;j++){
      c[i][j] = -1;
    }
  }

  scanf("%d",&n);

  k = (int *)malloc(n * sizeof(int));
  d = (int *)malloc(n * sizeof(int));
  p = (int *)malloc(n * sizeof(int));

  for(i = 0;i < n;i++){
    k[i] = 0;
    d[i] = 0;
    p[i] = -1;
  }


  for(i = 0;i < n;i++){
    scanf("%d",&id);
    scanf("%d",&k[id]);

    if(k[id] > 0){
      for(j = 0;j < k[id];j++){
	scanf("%d",&c[id][j]);
      }
    }
  }

  for(i = 0;i < n;i++){
    for(j = 0;j < k[i];j++){
      if(c[i][0] >= 0){
	p[c[i][j]] = i;
      }
    }
  }

  for(i = 0;i < n;i++){
    j = i;
    while(1){
      if(p[j] == -1)break;
      d[i]++;
      j = p[j];
    }
  }

  for(i = 0;i < n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,p[i],d[i]);
    if(p[i] == -1){
      printf("root, ");
    }
    else if(c[i][0] >= 0 && p[i] != -1){
      printf("internal node, ");
    }
    else{
      printf("leaf, ");
    }

    printf("[");
    if(c[i][0] >= 0){
      for(j = 0;;){
	printf("%d",c[i][j]);
	j++;
	if(j == k[i])break;
	printf(", ");
      }
    }
    printf("]\n");
  }

  return 0;
}