#include <stdio.h>

typedef struct{
  int id;
  int child;
  int brother;
  int parent;
} Node;

Node tree[100000];

int main(){
  int i,j,n,num,ch,id,prev,br=0,depth=0;
  char type;
 
  scanf("%d",&n);

  for(i=0;i<n;i++){
    tree[i].parent=-1;
    tree[i].child=-1;
    tree[i].brother=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id, &num);
    tree[id].id = id;
    for(j=1;j<=num;j++){
      scanf("%d",&ch);
      if(j==1) tree[id].child=ch;
      tree[ch].parent=id;
      if(j!=1) tree[prev].brother=ch;
      prev = ch;   
    }
  }

  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",tree[i].id,tree[i].parent);
    j=i;
    while(tree[j].parent!=-1){
      j=tree[j].parent;
      depth++;
    }
    if(i==0) printf("depth = %d, root, [",depth);
    else if(tree[i].child != -1 && i!=0){ 
      printf("depth = %d, internal node, [",depth);
    }
    else if(tree[i].child==-1){ 
      printf("depth = %d, leaf, []\n",depth);
      depth=0;
      continue;
    } 
    depth=0;
    
    j=tree[i].child;
    while(tree[j].brother!=-1){ 
      printf("%d, ",j);
      j=tree[j].brother;
      br++;
    }
    printf("%d]\n",j);
  }
  return 0;
}