#include<stdio.h>
typedef struct{
  int a,b,c,d;
}Node;
Node SEA[100001];
int rec(int,int);
int main(){
  int e,f;
  int id,g,h,k,m;
  int i,j;
  scanf("%d",&e);
  for(i=0;i<e;i++){
    SEA[i].a=SEA[i].b=SEA[i].c=-1;
  }
  for(i=0;i<e;i++){
    scanf("%d%d",&id,&f);
    for(j=0;j<f;j++){
	scanf("%d",&g);
	if(j==0)SEA[id].b = g;
	else SEA[h].c=g;
	h = g;
	SEA[g].a = id;
      }
  }
  for(i=0;i<e;i++) if(SEA[i].a==-1)k = i;
  rec(k,0);

  for(i=0;i<e;i++){
    printf("node %d: parent = %d, depth = %d, ",i,SEA[i].a,SEA[i].d);
    if(SEA[i].a==-1)printf("root, ");
    else if(SEA[i].b!=-1)printf("internal node, ");
    else printf("leaf, ");
    printf("[");
    if(SEA[i].b!=-1){
      printf("%d",SEA[i].b);
      m = SEA[i].b;
      while(1){
	if(SEA[m].c==-1)break;
	else printf(", %d",SEA[m].c);
	m = SEA[m].c;
      }
    }
    printf("]\n");
  }
  return 0;
}
int rec(int r,int p){
  SEA[r].d = p;
  if(SEA[r].c!=-1)rec(SEA[r].c,p);
  if(SEA[r].b!=-1)rec(SEA[r].b,p+1);
}
