#include<stdio.h>
#define MAX 100000

typedef struct{
int p;
int l,r;
}Tree;

Tree A[MAX];

int Dep(int);

main(){
int i,j,n;
int num,deg,c,k=0;

scanf("%d",&n);
for(i=0;i<n;i++){
A[i].p=-1;
A[i].l=-1;
A[i].r=-1;
}
for(i=0;i<n;i++){
scanf("%d%d",&num,&deg);
for(j=0;j<deg;j++){
scanf("%d",&c);
if(j==0)A[num].l=c;
else A[k].r=c;
k=c;
A[c].p=num;
}
}
for(i=0;i<n;i++){
printf("node %d: parent = %d, depth = %d ",i,A[i].p,Dep(i));
if(Dep(i)==0)printf(", root, [");
else if(A[i].l==-1)printf(", leaf, [");
else printf(", internal node, [");
j=A[i].l;

while(j!=-1){
printf("%d",j);
j=A[j].r;
if(j!=-1){
printf(", ");
}
}
printf("]\n");
}
return 0;
}

int Dep(int num){
int dep=0;
while(A[num].p!=-1){
num=A[num].p;
dep++;
}
return dep;
}