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

#define ROOT 0
#define INTERNAL 1
#define LEAF 2

typedef struct{
  int id;
  int k;
  int p;
  int d;
  char type[14];
  int *child;
}DATA;

DATA Node[100000];


int depthsearch(int, int);

int main(){
  int i, j, n, idtemp, c, type;
  
  scanf("%d", &n);
  if(n >= 1 && n <= 100000){
    for(i = 0; i < n; i++) Node[i].p = -1;
    
    for(i = 0; i < n; i++){
      scanf("%d", &idtemp);
      Node[idtemp].id = idtemp;
      scanf("%d", &Node[idtemp].k);
      Node[idtemp].child = (int *)malloc(sizeof(int) * Node[idtemp].k);
      for(j = 0; j < Node[idtemp].k; j++){
	scanf("%d", &c);
	Node[idtemp].child[j] = c;
	Node[c].p = idtemp;
      }
    }

    for(i = 0; i < n; i++){
      Node[i].d = depthsearch(0, i);
      printf("node %d: parent = %d, depth = %d, ", i, Node[i].p, Node[i].d);
      
      if(Node[i].p == -1) printf("root, [");
      else if(Node[i].k != 0) printf("internal node, [");
      else printf("leaf, [");


      
      for(j = 0; j < Node[i].k; j++){
	if(j == Node[i].k - 1)
	  printf("%d", Node[i].child[j]);
	else
	  printf("%d, ", Node[i].child[j]);
      }
      printf("]\n");
    }

  }
  return 0;
}

int depthsearch(int d, int ids){
  
  if(Node[ids].p == -1) return d;
  
  ids = Node[ids].p;
  d = depthsearch(d + 1, ids);
 
  return d;
}

