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

typedef struct{
  int name;
  int degree;
  int child[100000];
  int parent;
  int depth;
  char *type;
} Node;

int main(){
  int n, i, j;
  Node *N;

  scanf("%d",&n);

  N = (Node *)malloc(sizeof(Node) * n);

  for(i = 0; i < n; i++){
    scanf("%d%d",&N[i].name, &N[i].degree);
    for(j = 0; j < N[i].degree; j++){
      scanf("%d",&N[i].child[j]);

      N[i].depth = 0;
    }
  }

  for(i = 0; i < n; i++){
    for(j = 0; j < N[i].degree; j++){
	N[N[i].child[j]].parent = N[i].name;
	N[N[i].child[j]].depth = N[N[i].child[j]].depth + 1;
    }



    if(N[i].depth == 0 || n == 1){
      N[i].type = "root";
      N[i].parent = -1;
    }
    
    else if(N[i].degree == 0) N[i].type = "leaf";

    else N[i].type = "internal node";
  }

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, %s, [", i, N[i].parent, N[i].depth, N[i].type);
    for(j = 0; j < N[i].degree; j++){
      printf("%d", N[i].child[j]);
      if(j != N[i].degree - 1) printf(", ");
    }
    printf("]\n");
  }

  return 0;
}