#include<stdio.h>
#include<stdlib.h>
typedef struct node{
  int id, deg, dpt;
  struct node *par;
  int *chl;
}T_node;
int cntdpt(T_node *);
int main(){
  int n;
  scanf("%d", &n);
  T_node *T;
  T = (T_node *)malloc(sizeof(T_node) * n);
  int i, id;
  for(i = 0; i < n; i++)
    T[i].par = NULL;
  for(i = 0; i < n; i++){
    scanf("%d", &id);
    T[id].id = id;
    scanf("%d", &(T[id].deg));
    T[id].chl = (int *)malloc(sizeof(int) * T[id].deg);
    int j;
    for(j = 0; j < T[id].deg; j++){
      scanf("%d", &(T[id].chl[j]));
      T[T[id].chl[j]].par = &(T[id]);
    }
  }
  for(i = 0; i < n; i++){
    T[i].dpt = cntdpt(&(T[i]));
    if(!T[i].dpt)
      printf("node %d: parent = %d, depth = %d, root, [", i, -1, T[i].dpt);
    else if(T[i].deg)
      printf("node %d: parent = %d, depth = %d, internal node, [", i, T[i].par->id, T[i].dpt);
    else
      printf("node %d: parent = %d, depth = %d, leaf, [", i, T[i].par->id, T[i].dpt);
    int j;
    for(j = 0; j < T[i].deg; j++){
      if(!j)
	printf("%d", T[i].chl[j]);
      else
	printf(", %d", T[i].chl[j]);
    }
    printf("]\n");
    free(T[i].chl);
  }
  free(T);
  return 0;
}

int cntdpt(T_node *t){
  if(t->par != NULL)
    return cntdpt(t->par) + 1;
}
  