#include<stdio.h>
#define N 100000

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[N];
int count = 0;


int depth(int id){
  if(T[id].parent == -1){
    return count;
  }

  else{
    count++;
    return depth(T[id].parent);
  }
}


void degree(int id){
  if(id != -1){
    if(count != 0){
      printf(", ");
    }
    printf("%d",id);
    count++;
    degree(T[id].right);
  }
}



int main(){
  int i,j,n,left,right,node,child,m;


  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }

  for(i=0 ; i<n ; i++){
    scanf("%d%d",&node,&m);
    for(j=0 ; j<m ; j++){
      scanf("%d",&child);
      T[child].parent = node;
      if(j != 0)T[left].right = child;
      else T[node].left = child;
      left = child;
    }
  }

  for(i=0;i<n;i++){
    count = 0;
   
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth(i));
    if(T[i].parent == -1) printf("root, [");
    else if(T[i].left == -1) printf("leaf, [");
    else  printf("internal node, [");
    count = 0;
    degree(T[i].left);
    printf("]\n");
  }
  return 0;
}