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

typedef struct node{
  int id;
  int p;
  int d;
  char type;
  int k;
  struct node *c;
  struct node *next;
  struct node *pre;
}T;

int n;

int main()
{
  int i,j,n_id,chil;
  T x;

  scanf("%d",&n);

  T t[n];

  for(i=0; i<n; i++){
    t[i]->d = 0;
  }

  for(i=0 i<n; i++){
    scanf("%d",&n_id);
    scanf("%d",&t[n_id]->k);

    t[n_id]->id = n_id;

    if(t[n_id].k==0){
      t[n_id].type = 'l';
      t[n_id]->c == NULL;
      continue;
    }
    else{
      t[n_id].type = 'i';
    }

    for(j=0; j<t[n_id]->k; j++){
      scanf("%d",&chil);
      t[chil]->p = n_id;
      t[chil]->d = t[n_id]->d + 1;
      if(j==0){
	t[n_id]->c = t[chil];
	t[n_id]->c->next = NULL;
	t[n_id]->c->pre = NULL;
	x = t[n_id]->c;
      } else {
	x->next = t[chil];
	x->pre = x;
	x = x->next;
      }
      while(x->pre == NULL){
	x = x->pre;
      }
      t[n_id]->c = x;
    }
  }

  for(i=0; i<n; i++){
    if(t[i]->d == 0){
      t[i]->type = 'r';
      t[i]->p = -1;
    }
    printf("node %d: parent = %d, depth = %d, ",t[i]->id, t[i]->p, t[i]->d);

    switch(t[i]->type){

    case 'l':
      printf("leaf, []\n");
      break;

    case 'i':
      printf("internal node, [");
      x = t[i]->c;
      for(j=0; j<t[i]->k-1; j++){
	printf("%d, ",x->id);
	x = x->next;
      }
      printf("%d]\n",x->id);
      break;

    case 'r':
      printf("root, [");
      x = t[i]->c;
      for(j=0; j<t[i].k; j++){
	if(j!=0)
	  printf(", ");
	printf("%d",x);
	x = x->next;
      }
      printf("]\n");
      break;
    }
  }

  
  return 0;
}

    
    
  
  

