#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int parent;
  int left_child;
  int next_sibling;
  int child;
}node;
int depth(int);
node *T;
int count;
int main(){
  char c;
  int n, x, y, z, a, i, j;
  scanf("%d",&n);
  T = (node *)malloc(sizeof(node) * n);
  for(i=0; i<n; i++) T[i].parent = -1;
  for(i=0; i<n; i++){
    scanf("%d",&x);
    scanf("%d",&z);
    T[x].child = z;
    for(j=0; j<z; j++){
      if(j == 0){
	scanf("%d",&y);
	T[y].parent = x;
	T[x].left_child = y;
      }
      else{
	scanf("%d",&T[y].next_sibling);
	T[y].parent = x;
	T[T[y].next_sibling].parent = x;
	y = T[y].next_sibling;
      }
    }
  }
  for(i=0; i<n; i++){
    count=0;
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth(i));
    if(T[i].parent == -1) printf("root, [");
    else if(T[i].child == 0) printf("leaf, [");
    else printf("internal node, [");
    for(j=0; j<T[i].child; j++){
      if(j == 0){
	printf("%d",T[i].left_child);
	x = T[T[i].left_child].next_sibling;
      }
      else{
	printf("%d",x);
	x = T[x].next_sibling;
      }
      if(j != T[i].child - 1) printf(", ");
    }
    printf("]\n");
  }
  free(T);
  return 0;
}

int depth(int x){
  if(T[x].parent == -1) return count;
  else{
    count++;
    depth(T[x].parent);
  }
  return count;
}