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

#define MAX 100001

typedef struct node{
  int k;
  int p;
  int c[MAX];
  int right;
  int left;
}Node;

Node node[MAX],tmp;

int main(){
  
  int n,i,j,l,c,k,id,tmpP,depth;
  
  //in
  scanf("%d",&n);
  
  //initialize
  for(i=0;i<n;i++){
    node[i].p = -1;
    node[i].right = -1;
    node[i].left = -1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    node[id].k = k;
    
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0) node[id].left = c;
      else node[id].right = c;
      node[id].c[j]= c;
      node[c].p = id;
    }
  }
  
  //depthSearch & typeJudge
  for(i=0;i<n;i++){
    depth = 0;
    tmpP = node[i].p;
    
    while(tmpP != -1){
      tmpP = node[tmpP].p;
      depth++;
    }
    
    if(node[i].p == -1){
      printf("node %d: parent = %d, depth = %d, root, [",
	   i,node[i].p,depth);
    }
    else if(node[i].k == 0) printf("node %d: parent = %d, depth = %d, leaf, [",
	   i,node[i].p,depth);
    else printf("node %d: parent = %d, depth = %d, internal node, [",
	   i,node[i].p,depth);
    
    for(j=0;j<node[i].k;j++){
      if(j==0) printf("%d",node[i].c[j]);
      else printf(", %d",node[i].c[j]);
    }
    printf("]\n");
  }

  return 0;
}