#include<stdio.h>
#define NUM 100000

typedef struct Node{
  int parent,left,right;
    }Node;
  
Node T[NUM];
int n,D[NUM];

void print(int a){
  int i,b;

  printf("node %d: parent = %d, depth = %d, ", u, T[a].parent, D[a]);

  if(T[a].parent == -1)
    printf("root, [");

  else if(T[a].left == -1)
    printf("leaf, [");

  else
    printf("internal node, [");

  b = T[a].left;

  for(i = 0; b != -1; i++, b = T[b].right){
    if(i)
      printf(", ");

    printf("%d", b);
  }

  printf("]\n");
}

int depth(int a, int b){
  D[a] = b;
 
  if(T[a].right != -1)
    depth(T[a].right, b);

  if(T[a].left != -1)
    depth(T[a].left, b+1);
}

int main(){
  int a,b,c,left,right,i,j;

  scanf("%d", &n);

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

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