#include<stdio.h>

struct Tree {
  int id;
  int k;
  int c[20];
  int parent;
  int depth;
};

int depth(int);
struct Tree data[100];

int main()
{
  int n, i, j, flag, k;
  struct Tree temp;
  char *str[] = {"root", "internal node", "leaf"};

/* ??\??? */
  scanf("%d", &n);

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

  for(i = 0; i < n; i++){
    data[i].parent = -1;
    data[i].depth = 0;
  }

/* parent?????? */
  for(i = 0; i < n; i++){
    for(j = 0; j < data[i].k; j++){
      for(k = 0; k < n; k++){
	if(i == 0) data[i].parent = -1;
	if(data[i].c[j] == data[k].id){
	  data[k].parent = data[i].id;
	  data[k].depth = data[j].id;
	}
      }
    }
  }

/* ?????????sort */
  flag = 1;
  j = 0;
  while(flag){
    if(n == 1) break;
    flag = 0;
    for(i = n-1; i >= 1; i--){
      if(data[i].id < data[i-1].id){
	temp = data[i-1];
	data[i-1] = data[i];
	data[i] = temp;
	flag = 1;
	j++;
      }
    }
  }

  /* depth */
  for(i = 0; i < n; i++){
    data[i].depth = depth(data[i].parent);
  }

/* ?????? */
  for(i = 0; i < n; i++){
    printf("node %d: ", data[i].id);
    printf("parent = %d, ", data[i].parent);
    printf("depth = %d, ", data[i].depth);
    
    if(data[i].parent == -1) printf("%s, ", str[0]);
    else if(data[i].parent != -1 && data[i].c[0] == 0) printf("%s, ", str[2]);
    else printf("%s, ", str[1]);

    printf("[");
    for(j = 0; j < data[i].k; j++){
      if(j == 0) printf("%d", data[i].c[j]);
      else printf(", %d", data[i].c[j]);
    }
    
    printf("]\n");
  } 

  return 0;
}
  
int depth(int p)
{
  int count=0;

  if(p == -1) return 0;
  else{
    count++;
    return count + depth(data[p].parent);
  }
}