#include<stdio.h>
#include <stdlib.h>
#define N 100000

typedef struct{
  int p;
  int k;
  int *child;
}Node;

int depth(Node*,int,int);

int main(){
  int num,i,j,k,number;
  Node node[N]; 
  
  scanf("%d",&num);

  for(i=0; i<num; i++) node[i].p = -1;
  
  for(i=0; i<num; i++){
    scanf("%d",&number);
    scanf("%d",&node[number].k);
    node[number].child = (int *)malloc(sizeof(int) * node[number].k);
    for(j=0; j<node[number].k; j++){
      scanf("%d",&node[number].child[j]);
      node[node[number].child[j]].p = number;
    }
  }
  
  
  for(i=0; i<num; i++){
    printf("node %d: parent = %d, ",i,node[i].p);
    printf("depth = %d, ",depth(node,i,0));
    
    if(node[i].p==-1) printf("root, [");
    else if(node[i].k==0) printf("leaf, [");
    else printf("internal node, [");
    
    for(j=0; j<node[i].k; j++){
      printf("%d",node[i].child[j]);
      if(j+1<node[i].k) printf(", ");
    }
    printf("]\n");
  }
  

  return 0;
}


int depth(Node *node,int num,int count){
  if(node[num].p==-1)return count;
  count++;
  count = depth(node,node[num].p,count);

  return count;
}