#include <stdio.h>
#define N 100000

struct Node{
  int parent;
  int left;
  int right;
};

struct Node tree[N];
int n, d[N];

void depth(int, int);
void print(int);
 
int main(){
  int i, j, id, k, c, left = 0, right = 0;

  scanf("%d", &n);
  for(i = 0;i < n;i++) tree[i].parent = tree[i].left = tree[i].right = -1;
  for(i = 0;i < n;i++){
    scanf("%d%d", &id, &k);
    for(j = 0;j < k;j++){
      scanf("%d", &c);
      if(j == 0) tree[id].left = c;
      else tree[left].right = c;
      left = c;
      tree[c].parent = id;
    }
  }
  for(i = 0;i < n;i++){
    if(tree[i].parent == -1) right = i;
  }
  depth(right, 0);
  for(i = 0;i < n;i++) print(i);
  return 0;
}

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, tree[u].parent, d[u]);
  if(tree[u].parent == -1) printf("root, ");
  else if(tree[u].left == -1) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i = 0, c = tree[u].left;c != -1;i++, c = tree[c].right){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

void depth(int u, int p){
  d[u] = p;
  if(tree[u].right != -1) depth(tree[u].right, p);
  if(tree[u].left != -1) depth(tree[u].left, p + 1);
}