#include<stdio.h>

#define MAX 100000
#define NIL -1

void getDepth(int,int);
void print(int);

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

struct Node Tree[MAX]; 
int D[MAX],n;
 
int main(){

  int i,j,node,degree,child,left,right;

  scanf("%d",&n);

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

  for(i=0;i<n;i++){
    scanf("%d%d",&node,&degree);
    for(j=0;j<degree;j++){
      scanf("%d",&child);
      if(j==0){
	Tree[node].left=child;
      }
      else Tree[left].right=child;
      left = child;
      Tree[child].parent = node;
    }
  }
  
  for(i=0;i<n;i++){
    if(Tree[i].parent==NIL){
      right=i;
    }
  }
  getDepth(right,0);

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

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

void getDepth(int u,int d){
  D[u] = d;
  if(Tree[u].right!=NIL){
    getDepth(Tree[u].right,d);
  }
  if(Tree[u].left!=NIL){
    getDepth(Tree[u].left,d+1);
  }
}