#include<stdio.h>

int parent[10000];
int count[10000];
int root[10000];
int flag[10000];
int depth(int);

int main()
{
  int i,n,k,id,c,node=0;

  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    parent[i] = -1;
    flag[i] = 1;
  }
  
  for(i=0; i<n; i++){
    scanf("%d %d",&id,&k);
    count[id]=k;

    while(k-->=1){
      scanf("%d",&c);
      root[node++]=c;
      parent[c]=id;
      flag[id]=0;
    }
  } 
   for(i=0; i<n; i++){
      int j,l;
      printf("node %d: parent = %d, depth = %d, ",i,parent[i],depth(i));

      if(flag[i] == 1)
	printf("leaf,[]\n");

      else if(depth(i) == 0){
	printf("root,[");
	for(j=0; j<count[i]-1; j++){
	    printf("%d,",root[j]);
	    }
	  printf("%d]\n",root[j]);
	  l=j+1;
      }

      else{
	printf("internal node, [");
	for(j=0; j<count[i]-1; j++){
	    printf("%d,",root[l++]);
	    }
	  printf("%d]\n",root[l++]);
      }
    }
    return 0;
}

int depth(int i){
  if(parent[i] == -1)return 0;
  else return depth(parent[i])+1;
}

