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

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

void addChild(int x, int c) {
  int p;
  if(child[x] == -1) {
    child[x] = c;
  } else {
    p = child[x];
    while(sibing[p] != -1) {
      p = sibing[p];
    }
    sibing[p] = c;
  }
}

int main() {
  int i,j,k;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    parent[i] = -1;
    isLeaf[i] = 1;
    child[i] = -1;
    sibing[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;
      addChild(id, c);
      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("[");
    for(j = child[i]; j != -1; j = sibing[j]) {
      if(j != child[i]) printf(", ");
      printf("%d", j);
    }
    printf("]\n");
  }
  return 0;
}