#include <stdio.h>
#include <string.h>

#define MAX 100000

struct Node{
  int id;
  int k;
  int p;
  int d;
  char type[14];
  int c[MAX];
};

int main(){
  int i,j,k,n;

  scanf("%d",&n);

  struct Node u[n];

  for(i=0;i<n;i++){
    scanf("%d%d",&u[i].id,&u[i].k);
    if(u[i].k!=0){
      for(j=0;j<u[i].k;j++) scanf("%d",&u[i].c[j]);
    }
  }

  u[0].p=-1;
  u[0].d=0;
  strcpy(u[0].type,"root");

  for(i=0;i<n;i++){
    for(j=0;j<u[i].k;j++){
      for(k=i+1;k<n;k++){
	if(u[k].id==u[i].c[j])  u[k].p=u[i].id;
      }
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(u[i].p==u[j].id) u[i].d=u[j].d+1;
    }
  }

  for(i=1;i<n;i++){
    if(u[i].c[0]!=NULL) strcpy(u[i].type,"internal node");
    else strcpy(u[i].type,"leaf");
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, %s, [",u[i].id,u[i].p,u[i].d,u[i].type);
    if(u[i].c[0]!=NULL){
      for(j=0;j<u[i].k-1;j++) printf("%d, ",u[i].c[j]);
      printf("%d]\n",u[i].c[u[i].k-1]);
    }
    else printf("]\n");
  }

  return 0;
}