#include<stdio.h>
#define N 100000
#define NIL -1

typedef struct{

  int pid;//親のID
  int leftc;//自分の子供の一番左の子
  int rights;//自分のすぐ右隣の兄弟
  
}Rooted;

int type(int,int);
int depth(int,int);

Rooted data[N];
int D[N];

int main(){

  int i,j,t,n,id,c,k,oldc,root;

  scanf("%d",&n);//接点の数

  for(i=0;i<n;i++){
    data[i].pid=NIL;
    data[i].leftc=NIL;
    data[i].rights=NIL;
  }

  for(i=0;i<n;i++){

    scanf("%d%d",&id,&k);

    for(j=0;j<k;j++){

      scanf("%d",&c);

      data[c].pid=id;

      if(j==0){
	data[id].leftc=c;
      }

      if(j>=1){
	data[oldc].rights=c;
      }

      oldc=c; 

    }//for

  }//for

  c=-1;

  for(i=0;i<n;i++){

    if(data[i].pid==NIL){
      root=i;
    }
    
  }

  depth(root,0);

  for(i=0;i<n;i++){

    printf("node %d: ",i);

    printf("parent = %d, ",data[i].pid);

    printf("depth = %d, ",D[i]);

    t=type(data[i].pid,data[i].leftc);
    if(t==-1) printf("root, ");
    else if(t==0) printf("leaf, ");
    else printf("internal node, ");

    printf("[");

    if(data[i].leftc!=NIL){

      printf("%d",data[i].leftc);

      c=data[data[i].leftc].rights;

	while(c!=NIL){
	  printf(", %d",c);
	  c=data[c].rights;
	 
	}

   
     

    }//if

    printf("]\n");

  }//for

  return 0;
  
}

int type(int pid,int leftc){
  if(pid==-1) return -1;
  else if(leftc==-1) return 0; 
  else return 2;
}

int depth(int i,int dep){

  D[i]=dep;

  if(data[i].rights!=NIL){
    depth(data[i].rights,dep);
  }

  if(data[i].leftc!=NIL){
    depth(data[i].leftc,dep+1);
  }
  
  
}

