#include <stdio.h>
#define N 100000

typedef struct{
  int id;
  int k;
  int c[20];
  int p;
  int d;
  int type;
  int flag;
}Node;
Node node[N];

int main(){
  int i,j,k,n,tmp;
  Node copy;
  
  scanf("%d",&n);
  if(n<0 || n>100001){
    printf("Error\n");
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&node[i].id);
    scanf("%d",&node[node[i].id].k);
    for(j=0;j<node[node[i].id].k;j++){
      scanf("%d",&node[node[i].id].c[j]);
      node[node[node[i].id].c[j]].p = node[i].id;
      node[node[node[i].id].c[j]].flag = 1;
    }
    node[node[i].id].d = 0;                         /*depthの初期化*/
  }

  for(i=0;i<n;i++){
    //    printf("flag: %d\n",node[i].flag);
    if(node[i].flag == 0){
      node[i].p =  -1; 
    }
  }
  /*Search depth*/
  for(i=0;i<n;i++){
    if(node[i].k == 0) node[i].type = 2;   /*leaf*/
    else  node[i].type = 1;                /*internal node*/
    if(node[i].flag == 0)node[i].type = -1;/*root*/
    tmp = node[i].p;
    if(tmp == -1)continue;
    while(tmp != -1){
      node[i].d++;
      tmp = node[tmp].p;
    }
  }
   
  /*Input*/
   for(i=0;i<n;i++){
     printf("node %d: parent = %d, depth = %d, ",i,node[i].p,node[i].d);
     if(node[i].type == -1) printf("root, [");             
     else if(node[i].type == 1) printf("internal node, [");
     else printf("leaf, [");                               
     for(j=0;j<node[i].k;j++){
       if(j == 0){
	 printf("%d",node[i].c[0]);
	 continue;
       }
       if(j < node[i].k){
	 printf(", %d",node[i].c[j]);
       }
     }
     printf("]\n");
   }
   
   return 0;
}


