#include <stdio.h>

#define N 100001
 
int depth(int);
void output(int);
 
typedef struct{
   
  int parent;

  int left;

  int right;

}Node;  
 
Node tree[N];

int count;
 
int main(){
  
  int i, j, n, k, Nnode, child, l;
  
  scanf("%d", &n);
     
  for(i = 0 ; i < n ; i++){

    tree[i].parent = -1;

    tree[i].left = -1;

    tree[i].right = -1;

  }

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

    scanf("%d %d", &Nnode, &k);

    for(j = 0 ; j < k ; j++){

      scanf("%d", &child);

      if(j == 0)
	tree[Nnode].left = child;
      else
	tree[l].right = child;
             
      l = child;

      tree[child].parent = Nnode;

    }

  }

  for(i = 0 ; i < n ; i++){
    count = 0;

    printf("node %d: parent = %d, depth = %d, ", i, tree[i].parent, depth(i));
         
    if(tree[i].parent == -1)
      printf("root, [");
    else if(tree[i].left == -1)
      printf("leaf, [");
    else
      printf("interal node, [");
	         
    count = 0;

    output(tree[i].left);

    printf("]\n");

    }

    return 0;

}
 
int depth(int a){

    if(tree[a].parent != -1){

        count++;

        return depth(tree[a].parent);

    }

    else
      return count;

}
 
void output(int b){
    
  if(b != -1){
    
    if(count != 0)
      printf(", ");
         
    count++;

    printf("%d", b);

    output(tree[b].right);

    }
  
}