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

#define MAX 100001

typedef struct{
  int parnodnm;
  int depth;
  int typ;
  int chilnm;
  int *child;
  // int child[100];
}Node;

Node T[MAX];

int calcudepth(int u){
  int d = 0;
  while(T[u].parnodnm != -1){
    u = T[u].parnodnm;
    d++;
  }
  return d;
}

int main(){
  int nm, i, j, nodnm;
  int D[MAX];

  scanf("%d", &nm);

  for(i = 0; i < nm; i++) T[i].parnodnm = -1; //parnod initialize
  
  for(i = 0; i < nm; i++){
    scanf("%d", &nodnm);
    scanf("%d", &T[nodnm].chilnm);
    if(T[nodnm].chilnm > 0){
      T[nodnm].child = (int *)malloc(T[nodnm].chilnm * sizeof(int));
      T[nodnm].typ = 2;  //0:root 1:leaf 2:internal node 
      for(j = 0; j < T[nodnm].chilnm; j++){
	scanf("%d", &T[nodnm].child[j]);
	T[T[nodnm].child[j]].parnodnm = nodnm;
      }
    }
    else if(T[nodnm].chilnm == 0) T[nodnm].typ = 1;
  }

  for(i = 0; i < nm; i++)
    if(T[i].parnodnm == -1) T[i].typ = 0;

  for(i = 0; i < nm; i++) T[i].depth = calcudepth(i);

  for(i = 0; i < nm; i++){
    if(T[i].typ == 0)
      printf("node %d: parent = %d, depth = %d, root, ", i, T[i].parnodnm, T[i].depth);
    else if(T[i].typ == 1)
      printf("node %d: parent = %d, depth = %d, leaf, ", i, T[i].parnodnm, T[i].depth);
    else if(T[i].typ == 2)
      printf("node %d: parent = %d, depth = %d, internal node, ", i, T[i].parnodnm, T[i].depth);
    printf("[");
    if(T[i].chilnm > 0){ 
    for(j = 0; j < T[i].chilnm-1; j++) printf("%d, ", T[i].child[j]);
    printf("%d]\n", T[i].child[j]);
    }
    else printf("]\n");
  }
   
  return 0;
}

