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

int main(){
  int kazu,i,j,id,k,a,temp,depth,parent[MAX],left[MAX],right[MAX],degree[MAX];
  scanf("%d",&kazu);
  for(i=0;i<kazu;i++) parent[i]=left[i]=right[i]=NIL;
  for(i=0;i<kazu;i++){
    scanf("%d %d",&id,&k);
    degree[id]=k;
    for(j=0;j<k;j++){
      if(left[id]==NIL){
	scanf("%d",&a);
	left[id]=a;
	parent[a]=id;
	temp=left[id];
      }else{
	scanf("%d",&a);
	right[temp]=a;
	parent[a]=id;
	temp=a;
      }
    }
  }
  for(i=0;i<kazu;i++){
    printf("node %d: parent = %d,",i,parent[i]);
    depth=0;
    a=i;
    while(parent[a]!=NIL){
      a=parent[a];
      depth++;
    }
    printf(" depth = %d,",depth);
    if(parent[i]==NIL) printf(" root, [");
    else if(left[i]==NIL) printf(" leaf, [");
    else printf(" internal node, [");
    a=left[i];
    for(j=0;j<degree[i];j++){
      if(j) printf(", ");
      printf("%d",a);
      a=right[a];
      }
    printf("]\n");
  }
  return 0;
}

