#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct {
  int parent;
  int right;
  int left;
} _T;
_T T[MAX];

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

int main(){
  int i, j, d, v, c, l, n;
 /*d = degreenumber, v = Vertexnumber, c = current*/
 scanf("%d", &n);
  
	for(i=0;i<n;i++){
   T[i].parent = T[i].left = T[i].right = NIL;
   }
  
	   for ( i = 0; i < n; i++ ){
    
    scanf("%d %d",&v,&d);
    
 for(j=0;j<d;j++){
      scanf("%d",&c);
      T[c].parent = v;
      
	       if(j==0){
		 T[v].left = c;
	       }
	       else if(j>0){
		 T[l].right = c;
	       }
      l = c;
      
	       }
    }
		
	for (i=0;i<n;i++){
    print(i);
    }
	
 return 0;
}