#include <stdio.h>
#include <stdlib.h>

#define N 10000

typedef struct{
  int id;
  int p;
  int c;
  int right_sibling;
  int child[N];
} Tree;

int n;
Tree T[N];

void print(){

  int i,j;

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

int getdepth(u){

  int i,d = 0;

  while(T[u].p >= 0){
    u = T[u].p;
    d++;
  }
  return d;
}


int main(void){

  int i,j,k=0,node,deg;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].id = 0;
    T[i].p = -1;
    T[i].c = 0;
    for(j=0;j<n;j++){
      T[i].child[j] = -1;
    }  
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&node,&deg);
    T[i].id = node;
    T[i].c = deg;
    for(j=0;j<deg;j++){
      scanf("%d",&T[i].child[j]);
      T[T[i].child[j]].p = node;
      } 
    k = 0;
  }
  print();
  return 0; 
}