#include<stdio.h>
#include<string.h>
struct node{
  int id;
  int chil;
  int c[13];
  int p;
  int de;
  char type[13];
};
struct node u[13];
int dep=0;
int depth(struct node *,int);
int main(){
  int n,i,j,k,c,flag,min;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    u[i].p=-1;
    u[i].de=0;
  }
  struct node sw;
  for(i=0;i<n;i++){
    scanf("%d %d",&u[i].id,&u[i].chil);
    for(j=0;j<u[i].chil;j++){
      scanf("%d",&u[i].c[j]);
    }
  }
  for(i=0;i<=n-2;i++){
    min=i;
    for(j=i;j<=n-1;j++){
      if(u[j].id<u[min].id){
	min=j;
	flag=1;
      }
    }
    if(flag==1){
      flag=0;
    }
    sw=u[i];
    u[i]=u[min];
    u[min]=sw;
  }
for(i=0;i<n;i++){
  if(u[i].chil==0)strcpy(u[i].type,"leaf");
  for(j=0;j<u[i].chil;j++){  
    u[u[i].c[j]].p=u[i].id;
  }
 }
 
 for(i=0;i<n;i++){
   if(u[i].p==-1){
     strcpy(u[i].type,"root");
     u[i].de=0;
   }
   else if(strcmp(u[i].type,"leaf")!=0){
     strcpy(u[i].type,"internal node");
   }
 }
 for(i=0;i<n;i++){
   dep=0;
   u[i].de=depth(u,i);
 }
 for(i=0;i<n;i++){
   printf("node %d: parent = %d, depth = %d, %s, [",u[i].id,u[i].p,u[i].de,u[i].type);
   if(u[i].chil!=0)printf("%d,",u[i].c[0]);
   for(j=1;j<u[i].chil-1;j++){
     printf(" %d,",u[i].c[j]); 
   }
   if(u[i].chil!=0)printf(" %d]\n",u[i].c[u[i].chil-1]);
   else printf("]\n");
 }
 return 0;
}

int depth(struct node *a,int i){
  if((a+i)->p==-1)return dep;
  else if((a+i)->p!=-1)dep=depth(a,(a+i)->p)+1;
}