//Rooted tree
//2018-01-09
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>

void again (int, int);
void Print_tree (int);

#define N 1000000

typedef struct node { int p, l, r; } Node;
Node A[N];
int D[N];

int main(){
  int n, l, root;
  int v, d;
  int i, j;
  int c;

  scanf("%d", &n);
  if(n < 1 || 1000000 < n){
    printf("節点が適当ではありません。\n");
    exit(1);
  }
  for(i = 0 ; i < n ; i++){
    A[i].p = A[i]. l = A[i]. r = -1;
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d%d", &v, &d);

    for(j = 0 ; j < d ; j++){
      scanf("%d", &c);
      if(j == 0){
	A[v].l = c;
      }
      else{
	A[l].r = c;
      }
      l = c;
      A[c].p = v;
    }
  }
  for(i = 0 ; i < n ; i++ ){
    if(A[i].p == -1) root = i;
  }
  again(root, 0);
  for(i = 0 ; i < n ; i++) Print_tree(i);

  return 0;
}

void again(int a, int b){
  D[a] = b;
  if(A[a].l != -1) again(A[a].l, b+1);
  if(A[a].r != -1) again(A[a].r, b);
}

void Print_tree(int x){
  int i, a;
  printf("node %d: parent = %d, depth = %d, ", x, A[x].p, D[x]);
  if(A[x].p == -1)
    printf("root, ");
  else if(A[x].l == -1)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");
  
  for(i = 0, a = A[x].l ; a != -1 ; a = A[a].r, i++){
    if(i != 0)
      printf(", ");
    printf("%d", a);
    
  }
  printf("]\n");
}
  

