#include <stdio.h>
#define MAX 100000
#define NIL -1

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

struct Node T[MAX];
int D[MAX];
int getD(int);
void print(int);


int main()
{
  int n, k, node, c[MAX];
  int i, j;

  scanf("%d", &n);

  for(i=0; i<n; i++){
	T[i].parent = NIL;
	T[i].left = NIL;
	T[i].right = NIL;
  }

  for(i=0; i<n; i++){
	scanf("%d%d", &node, &k);
	for(j=0; j<k; j++){
	  scanf("%d", &c[j]);
	  
	  
	  T[c[j]].parent = node;
	  if(j==0) T[node].left = c[0];
	  else T[c[j-1]].right = c[j];
	}
  }
  
  for(i=0; i<n; i++){
	D[i] = getD(i);
  }

  for(i=0; i<n; i++){
	print(i);
  }

  return 0;
}

int getD(int i)
{
  int k=0;
  
  while(T[i].parent>=0){
	i = T[i].parent;
	k++;
  }

  return k;
}

void print(int i)
{
  int j, count=0;
  
  printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, D[i]);
  
  if(T[i].parent == NIL){
    printf("root, [");
  }
  else if(T[i].left == NIL){
    printf("leaf, [");
  }
  else{
    printf("internal node, [");
  }
  i = T[i].left;
  while(i != NIL){
    if(count==0) printf("%d", i);
    else printf(", %d", i);
	
    i = T[i].right;
    count++;  
  }
   
  printf("]\n");
   
}