#include <stdio.h>

struct node{
  int parent;
  int depth;
  int a[100];
  int k;
};
static struct node x[100000];

int main(){
  //printf("0\n");
  int i,j,u,n,k,m=100,c,d;
  //printf("1\n");

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    //printf("a\n");
    for(j=0;j<k;j++){
      scanf("%d",&x[u].a[j]);
      //printf("b\n");
    }
    if(i=0){
      x[u].parent=-1;
      x[u].depth=0;
    }
    x[u].k=k;
  }
  for(u=0;u<n;u++){
    if(x[u].parent==-1) continue;
    for(i=0;i<n;i++){
      for(j=0;j<x[i].k;j++){
        if(x[u].a[0]>x[i].a[j]){
          if(m>x[i].a[j]){
            m=x[i].a[j];
            c=i;
            d=j;
          }
        }
      }
    }
    x[u].parent=c;
    x[u].depth=x[c].depth+1;
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,x[i].parent,x[i].depth);
    if(x[i].parent==-1) printf("root, [");
    else if(x[i].k!=0) printf("internal node, [");
    else printf("leaf, [");

    for(j=0;j<x[i].k;j++){
      printf("%d",x[i].a[j]);
      if(j<k-1) printf(", ");
    }
    printf("]\n");
  }
  return 0;
}
