#include <stdio.h>
#include <stdlib.h>
#define NIL -1
#define Max 100005

struct Node { int parent , left , right;};
struct Node T[Max];

int n,D[Max];

void print(int u){
  int i,a;
  printf("node=%d",u);
  printf("parent=%d",T[u].parent);
  printf("depth=%d",D[u]);

  if(T[u].parent == NIL) printf("root, ");
  else if(T[u].left == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0,a=T[u].left;a!=NIL;i++,a=T[a].right){
    if(i) printf(", ");
    printf("%d",a);
  }

  printf("]\n");

}

void rec(int u, int p){
  D[u]=p;
  if(T[u].right!=NIL) rec(T[u].right,p);
  if(T[u].left!=NIL) rec(T[u].left,p+1);
}


int main(){

  int d,v,c,l,r,n,i,j;

  scanf("%d",&n);

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

  for(i=0;i<n;i++){
     scanf("%d",&v);
     scanf("%d",&d);

     for(j=0;j<d;j++){
       scanf("%d",&c);

       if(j==0)T[v].left=c;
       else T[l].right=c;
       l=c;
       T[c].parent=v;
     }
  }
  
  for(i=0;i<n;i++){
    if(T[i].parent==NIL)r=i;
  }

  rec(r,0);
  for(i=0;i<n;i++)print(i);

  return 0;
}
