#include<stdio.h>
#define N 100000

typedef struct{
  int id;
  int parent;
  int child;
  int right;
  int depth;
}Node;

Node node[N];
int C[N];

int main(){

  int n,i,j,degree=0,id=0;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    node[i].parent=-1;
    node[i].child=-1;
    node[i].right=-1;
    node[i].depth=0;
  }

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

    node[id].id=id;
    for(j=0;j<degree;j++){
      scanf("%d",&C[j]);
      if(j==0){
	node[id].child=C[j];
      }else if(j!=0){
	node[C[j-1]].right=C[j];
      }
      node[C[j]].parent=id;
      node[C[j]].id=C[j];
    }
  }

  for(i=0;i<n;i++){
    j=node[i].parent;

    while(1){
      if(j==-1){
	break;  
      }
      j=node[j].parent;
      node[i].depth++;
    }
  }

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