#include <stdio.h>
#define MAX 10000
typedef struct node{
  int pare;
  int left;
  int right;
}Node;

Node a[MAX];
int depth[MAX];
void searchdep(int,int);
int main(){
  int n,i,num,sum,j,tmp,k;
  scanf("%d",&n);
  for(i = 0 ;i<n ;i++){
    a[i].left = -1;
    a[i].right =-1;
    a[i].pare = -1;
  }
  
    for(i = 0 ;i<n ;i++){
      scanf("%d %d",&num,&sum);
      for(j = 0;j<sum;j++){
	scanf("%d",&tmp);
	if(j ==0) a[num].left = tmp;
	else {a[k].right= tmp;}
	  k=tmp;
	  a[k].pare = num;
      }
    }

    for(i =0;i<n;i++){
      if( a[i].pare == -1){
	searchdep(i,0);
      }

    }
    for(i =0 ;i<n;i++){
      if(a[i].pare ==-1){
	printf("node %d: parent = %d, depth = %d, root, ",i,a[i].pare,depth[i]);
	  printf("[");
	for(j = 0,tmp = a[i].left;tmp!=-1;j++,tmp = a[tmp].right){
	  if(j==0){
	  printf("%d",tmp);
	  }
	  else printf(", %d",tmp);
	    }
	printf("]\n");
      }
      else if(a[i].left !=-1 &&a[i].pare != -1){
	printf("node %d: parent = %d, depth = %d, internal node, ",i,a[i].pare,depth[i]);
	printf("[");
      for(j = 0,tmp = a[i].left;tmp!=-1;j++,tmp = a[tmp].right){
	  if(j==0){
	  printf("%d",tmp);
	  }
	  else printf(", %d",tmp);
	
	    }
	printf("]\n");
      }
      else if(a[i].left ==-1){
      	printf("node %d: parent = %d, depth = %d, leaf, []\n",i,a[i].pare,depth[i]);
    }
    }
    return 0;
}
      
void searchdep(int c ,int b){
  depth[c] = b;
  if(a[c].right !=-1){
    searchdep(a[c].right,b);
  }
  if(a[c].left != -1){
    searchdep(a[c].left,b+1);
  }
}

