#include <stdio.h>
struct tree{
  int num;
  int k;
  int c;
  int s;
  int p;
  int d;
};

int main(){

  int n,i,j,k,c,el,pa,pc;
  struct tree id[10000];
  scanf("%d",&n);//ノードの数
  for(i=0;i<n;i++){
    id[i].p=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&id[i].num,&id[i].k);//自分の番号、子供の数

    //  if(id[i].k==0)id[i].p=-1;

    for(j=0;j<id[i].k;j++){

      if(j==0){ 
	scanf("%d",&id[i].c);//子供1の番号
	id[id[i].c].p=i;
	el=id[i].c;

      }

      else{
	scanf("%d",&id[el].s);//兄弟の番号
	el=id[el].s;
	id[el].p=i;
      }
    }

  }
 
  for(i=0;i<n;i++){
    if(id[i].p==-1)continue;
    pa=id[i].p;
    pc=1;
    while(id[pa].p!=-1){
      pc++;
      pa=id[pa].p;
    }
  
    id[i].d=pc;
  }


  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d,",i,id[i].p,id[i].d);
    if(id[i].p==-1) printf(" root, ");

   else if(id[i].c==NULL) printf(" leaf, ");
    
    else printf(" internal node, ");

    printf("[");
    
    if(id[i].k!=0){ printf("%d,",id[i].c);
      el=id[i].c;
    }
    if(id[i].k>=2){
      for(j=0;j<id[i].k-1;j++){
	if(j==id[i].k-2)	printf(" %d",id[el].s);
	else printf(" %d,",id[el].s);
	el=id[el].s;
	//  if(id[i].k==3) printf("%d,",id[id[id[i].c].s].s);
      }

    }
printf("]\n");
  }
    return 0;
}