#include <stdio.h>
#define MAX 100000

typedef struct{
  int key;
  int child[MAX];
  int parent;
  int depth;
}Data;

int main(){
  int i,j,id,n,x,count=0,key;
  Data T[MAX];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent = -1;
    T[i].depth = 0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&T[id].key);
    key = T[id].key;
    for(j=0; j<key; j++){
      scanf("%d",&T[id].child[j]);
      T[T[id].child[j]].parent = id;
    }
  }

  for(id=0;id<n;id++){
    x = id;
    count = 0;
    while(T[x].parent != -1){
      x = T[x].parent;
      /*
      if(x != T[x].parent){
	printf("fxxx\n");
      }
      printf("x:%d T[x].parent:%d\n",x,T[x].parent);
      */
      count++;
    }
    T[id].depth = count;
  }

  for(id=0;id<n;id++){
    printf("node %d: parent = %d, depth = %d, ",id,T[id].parent,T[id].depth);
    if(T[id].depth == 0){
      printf("root, [");
      if(T[id].key == 0)printf("]\n");
      else{
	for(i=0;i<T[id].key-1;i++){
	  printf("%d, ",T[id].child[i]);
	}
	printf("%d]\n",T[id].child[T[id].key-1]);
      }
    }
    else if(T[id].key == 0)printf("leaf, []\n");
    else {
      printf("internal node, [");
      for(i=0;i<T[id].key-1;i++){
	printf("%d, ",T[id].child[i]);
      }
      printf("%d]\n",T[id].child[T[id].key-1]);
    }
  }
  
  return 0;
}