#include <stdio.h>
int N;
int parent[100001];
char isLeaf[100001];

int calcDepth(int i) {
  if(parent[i] == -1) return 0;
  return calcDepth(parent[i]) + 1;
}

int main() {
  int i,j,k;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    parent[i] = -1;
    isLeaf[i] = 1;
  }
  for(i = 0; i < N; ++i) {
    int id, k;
    scanf("%d %d", &id, &k);
    while(k--) {
      int c;
      scanf("%d", &c);
      parent[c] = id;
      isLeaf[id] = 0;
    }
  }
  for(i = 0; i < N; ++i) {
    int depth = calcDepth(i);

    printf("node %d: parent = %d, depth = %d, ", i, parent[i], depth);
    if(depth == 0) {
      printf("root, ");
    } else if(isLeaf[i]) {
      printf("leaf, ");
    } else {
      printf("internal node, ");
    }
    printf("[");
    k = 0;
    for(j = 0; j < N; ++j) {
      if(parent[j] == i) {
        if(k) printf(", ");
        else k = 1;
        printf("%d", j);
      }
    }
    printf("]\n");
  }
  return 0;
}