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

#define MAX 100000

struct Node{
  int p;
  int l;
  int r;
};

int main(){
  struct Node u[MAX];
  int i,j,n,id,k,d=0,t;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    u[i].p=-1;
    u[i].l=-1;
    u[i].r=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      if(j==0){
	scanf("%d",&u[id].l);
	t=u[id].l;
	u[t].p=id;
      }
      else{
	scanf("%d",&u[t].r);
	t=u[t].r;
	u[t].p=id;
      }
    }
  }

  for(i=0;i<n;i++){
    if(u[i].p==-1){
      printf("node %d: parent = -1, depth = 0, root, [",i);
      t=u[i].l;
      while(t!=-1){
	printf("%d",t);
	t=u[t].r;
	if(t!=-1) printf(", ");
      }
      printf("]\n");
    }
    
    else if(u[i].r==-1){
      d=0;
      printf("node %d: parent = %d, ",i,u[i].p);
      t=u[i].p;
      while(t!=-1){
	t=u[t].p;
	d++;
      }
      printf("depth = %d, internal node, [",d);
      t=u[i].l;
      while(t!=-1){
	printf("%d",t);
	t=u[t].r;
	if(t!=-1) printf(", ");
      }
      printf("]\n");
    }

    else{
      d=0;
      printf("node %d: parent = %d, ",i,u[i].p);
      t=u[i].p;
      while(t!=-1){
	t=u[t].p;
	d++;
      }
      printf("depth = %d, leaf, []\n",d);
    }
  }
  
  return 0;
}