#include<stdio.h>
#define NTL -1
typedef struct tree{
  int par;
  int lch;
  int rbro;
}tree;
int depth(int,tree *);
int type(int,tree *);
void cpri(int,tree *);
int main(){
  int n,i,j,now,chi,bchi,num;
  /*scan n*/
  scanf("%d",&n);
  tree t[n];
  /*NTL*/
  for(i=0;i<n;i++){
    t[i].par=NTL;
    t[i].lch=NTL;
    t[i].rbro=NTL;
  }
  /*scan tree*/
  for(i=0;i<n;i++){
    scanf("%d%d",&now,&num);
    for(j=0;j<num;j++){
      scanf("%d",&chi);
      if(j==0){
	t[now].lch = chi;
      }
      else t[bchi].rbro = chi;
      bchi = chi;
      t[chi].par = now;
    }
  }
  /* print*/
  for(i=0;i<n;i++){
    chi = i;
    printf("node %d: parent = %d, depth = %d",i,t[i].par,depth(i,t));
    if(type(i,t) == 1){
      printf(", root, [");
      cpri(i,t);
    }
    else if(type(i,t) == 2){
      printf(", internal node, [");
      cpri(i,t);
    }
    else if(type(i,t) == 3)printf(", leaf, []\n");
    
  }
  return 0;
}
int depth(int num,tree *t){
  int d=0;
  while(t[num].lch == NTL){
    d++;
    num = t[num].lch;
  }
  return d;
}
int type(int num,tree *t){
  if(t[num].par == NTL) return 1;/*root*/
  else if(t[num].lch != NTL) return 2;/*internal*/
  else if(t[num].lch == NTL) return 3;/*leaf*/
  return 3;
}
void cpri(int now,tree *t){
  int i,chi;
  chi = t[now].lch;
  for(i=0;chi!=NTL;i++){
    if(i != 0) printf(", ");
    printf("%d", chi);
    chi = t[chi].rbro;
  }
  printf("]\n");
}
