#include <stdio.h>
#define MAX 100000

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

Node T[MAX];
int n, D[MAX];
int rec(int,int);

int main(){
  int i, j, n, l, r, p, num, degree, child;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }
  for(i = 0; i < n; i++){
    scanf("%d%d",&num, &degree);
    for(j = 0; j < degree; j++){
      scanf("%d", &child);
      if(j == 0) T[num].left = child;
      else T[l].right =child;
      l = child;
      T[child].parent = num;
    }
  }
  for(i = 0; i < n; i++){
    if(T[i].parent == -1) r = i;
  }
  rec(r,0);
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i, T[i].parent, D[i]);
    if(T[i].parent == -1) printf("root, [");
    else if(T[i].left == -1) printf("leaf, [");
    else printf("internal node, [");
    p = T[i].left;
    for(j = 0; p != -1; j++, p = T[p].right){
      if(j) printf(", ");
      printf("%d", p);
    }
    printf("]\n");
  }

  return 0;
}

int rec(int r, int p){
  D[r] = p;
  if(T[r].right != -1) rec(T[r].right,p);
  if(T[r].left != -1) rec(T[r].left,p+1);
}