#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100000

typedef struct node{
 int id;
 int childnum;
 int parentid;
 int depth;
 char type[20];
 int start;
 int last;
}node;

void depthcheck(int x,node N[],int A[]){
int i;
if(N[x].start!=-1){
for(i=N[x].start;i<=N[x].last;i++){
 N[A[i]].depth=N[x].depth+1;
 depthcheck(A[i],N,A);
}
}


return;
}


int main(){
int n,i,j;
node N[MAX];
int A[MAX];
int right=0;
int x,y,z;

scanf("%d",&n);


/*-------------ノードの初期化-------------*/
for(i=0;i<n;i++){
N[i].id=i;
N[i].depth=0;
N[i].childnum=0;
N[i].parentid=-1;
N[i].start=-1;
N[i].last=-1;
A[i]=-1;
}
/*--------------------------------------*/




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

 scanf("%d %d",&x,&y);
 N[x].childnum=y;
 
 if(y==0){strncpy(N[x].type,"leaf",4);N[x].type[4]='\0';}
 else{/*子供あり*/

  N[x].start=right;
  for(j=0;j<y;j++){
      scanf("%d",&z);
      N[z].parentid=x;
      A[right]=z;
      right++;
  }
  N[x].last=right-1;

 }
}/*for end*/


for(i=0;i<n;i++)if(N[i].parentid==-1)break;

depthcheck(i,N,A);


for(i=0;i<n;i++){
 printf("node %d: ",i);
 printf("parent = %d, ",N[i].parentid);
 printf("depth = %d, ",N[i].depth);

 if(N[i].parentid==-1){strncpy(N[i].type,"root",4);N[i].type[4]='\0';}
 else if(N[i].parentid!=-1 && N[i].type[0]!='l'){strncpy(N[i].type,"internal node",13);N[i].type[13]='\0';}
 
 printf("%s, ",N[i].type);
 
 if(N[i].childnum==0)printf("[]\n");
 else if(N[i].childnum==1)printf("[%d]\n",A[N[i].start]);
 else{
  printf("[");
  for(j=N[i].start;j<N[i].last;j++)printf("%d, ",A[j]);
  printf("%d]\n",A[N[i].last]);
 }

}


return 0;
}
