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

 typedef struct{
   int parent;
   int left;
   int right;
 }Node;

int main(){
  int n, id, k, depth, a, i, j, b, c;
  Node *T;

  scanf("%d", &n);

  T = malloc(sizeof(Node)*n);

  for(i = 0; i < n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d", &id, &k);

    for(j = 0; j < k; j++){
      scanf("%d", &a);
      T[a].parent = id;

      if(j == 0)
	T[id].left = a;
      else if(j > 0)
	T[b].right = a;

      b = a;
    }
  }

  for(i = 0; i < n; j++){
    depth = 0;
    c = T[i].parent;

    while(c != -1){
      c = T[c].parent;
      depth++;
    }
    if(i ==0)
      printf("node %d: parent = %d, depth = %d, root, [", i, i-1, i);
    else if(T[i].left == -1)
      printf("node %d: parent = %d, depth = %d, leaf, [", i, T[i].parent, depth);
    else
      printf("node %d: parent = %d, depth = %d, internal node, [", i, T[i].parent, depth);

    c = T[i].left;
    if(c != -1)
      printf("%d", c);

    while(1){
      c = T[c].right;
      if(c != -1)
	ptintf(", %d", c);
      if(c == -1) break;
    }
    printf("]\n");
  }
  return 0;
}