#include<stdio.h>
#include<stdlib.h>
typedef struct list{
  int nodeid;
  int parent;
  int depth;
  int child_num;
  int *child_list;
  int type;
}node_list;

void renew_depth(node_list *,int);

int main(){
  int i,j,n,k,id,*child;
  node_list *A;

  scanf("%d",&n);

  A = malloc(sizeof(node_list)*n);
  for(i=0;i<n;i++){
    A[i].parent = -1;
    A[i].depth = 0;
    A[i].child_list =NULL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    A[id].nodeid=id;
    A[id].child_num=k;
    if(k>0){
      A[id].child_list = malloc(sizeof(int)*k);
      for(j=0;j<k;j++){
	scanf("%d",&A[id].child_list[j]);
	A[A[id].child_list[j]].parent = id;
	A[A[id].child_list[j]].depth += 1;
      }
    }
  }
  for(i=0;i<n;i++){
    if(A[i].parent ==  -1){
      renew_depth(A,i);
      break;
    }
  }  

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d,",i,A[i].parent,A[i].depth);
    if(A[i].depth == 0){
      printf(" root,");
    }
    else if(A[i].child_list == NULL){
      printf(" leaf,");
    }
    else printf(" internal node,");
    printf(" [");
    for(j=0;j<A[i].child_num;j++){
      if(j==0)printf("%d",A[i].child_list[j]);
      else printf(", %d",A[i].child_list[j]);
      
    }
    printf("]\n");
    free(A[i].child_list);
  }
  free(A);
  return 0;
}

void renew_depth(node_list *A,int i){
  int j;
  for(j=0;j<A[i].child_num;j++){
    A[A[i].child_list[j]].depth += A[i].depth ;
    renew_depth(A,A[i].child_list[j]);
  }
}
