#include<stdio.h>
#define MAX 1000
struct Rooted{
  int p,l,r;
};
  struct Rooted N[MAX];
  int n,H,D[MAX];

int Depth(int i){
  int d=0;
  while(N[i].p != -1){
    i=N[i].p;
    d++;
  }
  return d;
}
void print(int i){
  int j=0,c;
  printf("node %d: ",i);
  printf("parent = %d, ",N[i].p);
  printf("depth = %d, ",Depth(i));
  if(N[i].p==-1)printf("root, ");
  else if(N[i].l == -1)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  if(N[i].l != -1){
      printf("%d",N[i].l);
      c=N[i].l;
  while(c!=-1){ 
    printf(", %d",c);
     c=N[c].r;  
  }
  }
  printf("]\n");
}
    
int main(){
  int id,k,c;
  int i,j,l;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    N[i].p=-1;
    N[i].l=-1;
    N[i].r=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0){
	N[id].l=c;
      }
      else N[l].r=c;
      l=c;
      N[c].p=id;
    }
  }
  for(i=0;i<n;i++)print(i);
  return 0;
}

