#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int parent;
  int left;
  int right;
}Node;

int main(){
  int n,k,id,h,r,depth,p,i,j;
  Node *T;

  scanf("%d", &n);

  T=malloc(sizeof(Node)*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", &id, &k);
    for(j=0;j<k;j++){
      scanf("%d",&h);
      T[h].parent=id;

      if(j==0) T[id].left=h;
      else if(j>0) T[r].right = h;
      r=h;
    }
  }

  for(j=0;j<n;j++){
    depth=0;
    p=T[j].parent;

    while(p!=-1){
      p=T[p].parent;
      depth++;
    }

    if(depth==0){
      printf("node %d: parent = -1, depth = 0, root, [", j);
    }
    
    else if(T[j].left == -1){
      printf("node %d: parent = %d, depth = %d, leaf, [", j, T[j].parent, depth);
    }
    else{
      printf("node %d: parent = %d, depth = %d, internal node, [", j, T[j].parent, depth);
    }
 
    p = T[j].left;
    if(p != -1) printf("%d", p);
 
    while(p != -1){
      p = T[p].right;
      if(p != -1) printf(", %d", p);
    }
    printf("]\n");
  }
 
  return 0;
}