#include<stdio.h>
#define N 100000

typedef struct {
  int parent;
  int child[100];
  int m;
} Node;

Node Tree[N];

int getDepth(int x) {
  int depth = 1;
  if(Tree[x].parent == -1) return 0;
  depth += getDepth(Tree[x].parent);
  return depth;
}

int main() {
  int i, j, n;
  int number, depth; 

  scanf("%d", &n);
  for(i = 0; i < n; i++) Tree[i].parent = -1;
  for(i = 0; i < n; i++) {
    scanf("%d", &number);
    scanf("%d", &Tree[number].m);
    for(j = 0; j < Tree[number].m; j++) {
      scanf("%d", &Tree[number].child[j]);
      Tree[Tree[number].child[j]].parent = number;
    }
  }

  for(i = 0; i < n; i++) {
    depth = getDepth(i);
    printf("node %d: parent = %d, depth = %d, ", i, Tree[i].parent, depth);
    if(Tree[i].parent == -1) {
      printf("root, [");
      for(j = 0; j < Tree[i].m; j++) {
	if(j > 0) printf(", ");
	printf("%d",Tree[i].child[j]);
      }
      printf("]\n");
    }
    else if(Tree[i].m == 0) printf("leaf, []\n");
    else {
      printf("internal node, [");
      for(j = 0; j < Tree[i].m; j++) {
	if(j > 0) printf(", ");
	printf("%d",Tree[i].child[j]);
      }
      printf("]\n");
      }
    }
  return 0;
}