/*ツリー構造*/
#include <stdio.h>
#include <stdlib.h>
#define N 1000001

typedef struct node{
  int no;
  int depth;
  int nch;
  struct node *pa;
  int c[N];
} Node;

typedef struct node * NodePointer;

int n;

Node a[N], g;

void init();
void printTree(int);
void makeAll(int);
void relation(int, int *, int);
void depth(int);

void init(){
  //g = malloc(sizeof(struct node *));
  g.depth = -1;
  g.no = -1;
}

void makeAll(int n){
  int i, j;
  for (i=0; i<n; i++){
    a[i].no = i;
    a[i].pa = &g;
  }
}

void relation(int num, int *c, int x){
  int i;
  
  for(i=0; i<x; i++){
    a[c[i]].pa = &a[num];
  }
}


void depth(int n){
  int i, j, count=0;
  
  j=-1;
  while(j<N){
    for (i=0; i<n; i++){
      if (a[i].pa->depth == j){
	a[i].depth = j+1;
      }
    }
    j++;
  }
  
}

void printTree(int n){
  int i, j;
  
   for (i=0; i<n; i++){
     printf("node %d: parent = %d, depth = %d, "
	    , a[i].no, a[i].pa->no, a[i].depth);
     
     if (a[i].pa->no == -1){
       printf("root, [");
       for (j=0; j<a[i].nch; j++){
	 if (j == a[i].nch-1)
	   printf("%d", a[i].c[j]);
	 else
	   printf("%d, ",a[i].c[j]);
       }
       printf("]\n");
     }
     
     else if (a[i].nch != 0){
       printf("internal node, [");
       for (j=0; j<a[i].nch; j++){
	 if (j == a[i].nch-1)
	   printf("%d", a[i].c[j]);
	 else
	   printf("%d, ",a[i].c[j]);
       }
       printf("]\n");
     }
     
     else printf("leaf, []\n");
   }
}


int main(){
  int num, root, i, j;

  init();
  
  scanf("%d", &n);
  makeAll(n);
  
  for (i=0; i<n; i++){
    scanf("%d %d", &num, &root);
    a[num].nch = root;
    if (root!=0){
      for (j=0; j<root; j++)
	scanf("%d", &a[num].c[j]);
      relation(num, a[num].c, j);
    }
  }
  depth(n);

  printTree(n);
  
  return 0;
}

