#include <stdio.h>
#define MAX 100000
#define N -1

typedef struct Node{
  int poo,loo,roo;
}Node;

Node Ty[MAX];

int depth(int);
void p_degree(int);

int main(){

  int i,j,n,node,degree,children,left;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    Ty[i].poo = N;
    Ty[i].loo = N;
    Ty[i].roo = N;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&node,&degree);
    for(j = 0; j < degree; j++){
      scanf("%d",&children);
      Ty[children].poo = node;
      if(j == 0) Ty[node].loo = children;
      else Ty[left].roo = children;
      left = children;
    }
  }

  for(i = 0; i < n; i++){
      printf("node %d: parent = %d, depth = %d, ",i,Ty[i].poo,depth(i));
    
    if(Ty[i].poo == N) printf("root, [");
    else if(Ty[i].loo == N) printf("leaf, [");
    else printf("internal node, [");
    
    p_degree(Ty[i].loo);
    printf("]\n");
  }

  return 0;
}

int depth(int node)
{
  int count = 0;
  
  while(Ty[node].poo != N){
    count++;
    node = Ty[node].poo;
  }
  return count;
}

void p_degree(int i)
{
  if(i != N){
    if(Ty[i].roo == N) printf("%d",i);
    else printf("%d, ",i);
    p_degree(Ty[i].roo);
  }
}
    