#include <stdio.h>
#define N 100000
int depth (int);

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

node T[N];

int main () {
  int a, r, x, i, j, n, k;

  scanf("%d", &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", &a, &k);
    if(k != 0) {
	scanf("%d", &x);
	T[a].left = x;
	T[x].parent = a;
	r = x;
      }
      for(j = 1 ; j < k ; j++) {
	scanf("%d", &x);
	T[x].parent = a;
	T[r].right = x;
	r = x;
      }
  }
      
  for(i = 0 ; i < n ; i++) {
    printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, depth(i));
    if(T[i].parent == -1) {
      printf("root, ");
    }
    else if(T[i].left != -1) {
      printf("internal node, ");
    }
    else {
      printf("leaf, ");
    }
    printf("[");
    if(T[i].left != -1) {
      printf("%d", r=T[i].left);
    }
    while(T[r].right != -1) {
      printf(", %d", T[r].right);
      r = T[r].right;
    }
    printf("]\n");
  }
  return 0;
}
 
int depth(int x) {
  int c=0;
  while(T[x].parent >= 0) {
    c++;
    x = T[x].parent;
  }
  return c;
}