#include <stdio.h>
#include <stdlib.h>
 
typedef struct Node* NodePointer;
 
typedef struct Node {
  int key;
  NodePointer next;
} Node;
 
 
NodePointer child[100001];
NodePointer tail[100001];
int N;
int parent[100001];
char isLeaf[100001];
 
NodePointer makeNode(int key) {
  NodePointer p = (NodePointer)malloc(sizeof(Node));
  p->key = key;
  p->next = NULL;
  return p;
}
 
void add(int n, int x) {
  tail[n]->next = makeNode(x);
  tail[n] = tail[n]->next;
}
 
int calcDepth(int i) {
  if(parent[i] == -1) return 0;
  return calcDepth(parent[i]) + 1;
}
 
int main() {
  int i,j, k;
  int c, id, depth, flag;
  NodePointer p;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    parent[i] = -1;
    isLeaf[i] = 1;
    child[i] = makeNode(-1);
    tail[i] = child[i];
  }
  for(i = 0; i < N; ++i) {
    scanf("%d %d", &id, &k);
    while(k--) {
      scanf("%d", &c);
      parent[c] = id;
      add(id,c);
      isLeaf[id] = 0;
    }
  }
  for(i = 0; i < N; ++i) {
    depth = calcDepth(i);
    flag = 0;
    p;
    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(p = child[i]->next; p != NULL; p = p->next) {
      if(flag) printf(", ");
      else flag = 1;
      printf("%d", p->key);
    }
    printf("]\n");
  }
  return 0;
}