#include<stdio.h>
#define N 100000
typedef struct{ 
  int left;
  int right;
  int parent;
}id;
   
int main(){ 
  int n,i,j,k,d,t,x,c;
  id A[N];
 
  scanf("%d",&n);
  for(i=0;i<n;i++)
    A[i].parent = A[i].right = A[i].left = -1; 

  for(i=0;i<n;i++){
    scanf("%d %d",&k,&t); 

    for(j=0;j<t;j++){
      scanf("%d",&c);
      A[c].parent = k;

      if(j == 0)A[k].left = c;
      else A[x].right = c;

      x = c;
    }
  }
  
  for(i=0;i<n;i++){  
    x = A[i].parent;
    d = 0;
    
    while(x != -1){
      x = A[x].parent;
      d++;
    }
    
    printf("node %d: parent = %d, depth = %d, ",i,A[i].parent,d);
    
    if(A[i].parent == -1)printf("root, [");
    else if(A[i].left == -1)printf("leaf, [");
    else printf("internal node, [");
    
    x = A[i].left;
    
    if(x != -1){
      printf("%d",A[i].left);
      
      while(A[x].right != -1){
	printf(", %d",A[x].right);
	x = A[x].right;
      }
    }
    printf("]\n");
  }
  return 0;
}