#include<stdio.h>
typedef struct{
  int pt;
  int le;
  int ri;
} Tree;
Tree tree[1000000];
#define NIL -1
int main()
{
  int i,id,j,n,k,d[100000],depth=0,num;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    tree[i].pt=NIL;
    tree[i].le=NIL;
    tree[i].ri=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&d[j]);
      if(j==0){ tree[d[0]].pt=id; tree[id].le=d[0]; }
      else{ tree[d[j]].pt=id; tree[d[j-1]].ri=d[j]; }
    }
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,tree[i].pt);
    num=i;
    while(tree[num].pt!=NIL){ depth++; num=tree[num].pt; }
    printf("depth = %d,",depth);
    depth=0;
    if(tree[i].pt==NIL && tree[i].le==NIL){ printf(" root, []\n"); }
    else if(tree[i].pt==NIL && tree[i].le!=NIL){
      printf(" root, [%d",tree[i].le);
      for(j=tree[tree[i].le].ri;j!=NIL;j=tree[j].ri){
        printf(", %d",j);
      }
      printf("]\n");
    }
    
    else if(tree[i].le!=NIL){
      printf(" internal node, [%d",tree[i].le);
      for(j=tree[tree[i].le].ri;j!=NIL;j=tree[j].ri){
        printf(", %d",j);
      }
      printf("]\n");
    }
    
    else{ printf(" leaf, []\n"); }
    
  }
  return 0;
}

