#include<stdio.h>
#include<stdlib.h>
#define T 100000
typedef struct data{
  int p;
  int c;
  int b;

} DATA;
void print(int );
int re(int,int);
int D[T];
DATA C[T];
int main(){
  int o,i,j,a,b,s,l,r;
 
  scanf("%d",&o);
  for(i=0;i<o;i++){
    C[i].p=-1;
    C[i].c=-1;
    C[i].b=-1;
  }
 
  for(i=0;i<o;i++){
    scanf("%d %d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&s);
      if(j==0){
	C[a].c = s;
      }
      else {
	C[l].b = s;
      }
      l=s;
      C[s].p = a;
    }
  }
 
  for(i=0;i<o;i++){
    if(C[i].p == -1)
      r = i;
  }
  re(r,0);
  for(i=0;i<o;i++){
   

    print(i);
  }
  
  return 0;
}
int re(int r,int g){
  D[r]=g;
  if(C[r].b != -1)re(C[r].b,g);
  if(C[r].c != -1)re(C[r].c,g+1);

}
void print(int i){
  int a,b;
  printf("node %d: ",i);
  printf("parent = %d, ",C[i].p);
  printf("depth = %d, ",D[i]);

  if(C[i].p == -1)printf("root, ");
  else if(C[i].c == -1)printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  
  for(a=0,b=C[i].c;b!=-1;a++,b=C[b].b)
    {
    if(a)printf(", ");
    printf("%d",b);
  }
  printf("]\n");
    }

