#include<stdio.h>
#include<stdlib.h>
#define SIZE 100000

typedef struct node *link;
struct node{ 
	int v; link next; 
};



link NEW(int v, link n){ 
	link x = malloc(sizeof(*x));
	//x->v=v;x->next=n;
	//return x;
	x->v = v; x->next = NULL;
	if(n==NULL)return x;
	link t;
	for(t=n;t->next!=NULL;t=t->next);
	t->next = x;     
	return n;                         
}

int check(int a[],int n){
	int i;
	for(i=0;i<n;i++){
		if(a[i]==0)return 0;
	}
	return 1;
} 

void searchHead(int v[],int id,link a[]){
	link t;
	v[id]=1;
	if(a[id]==NULL)return;
	for(t=a[id];t!=NULL;t=t->next){
		searchHead(v,t->v,a);
	}
}

void search(int key,int id,link a[],int p,int d){
	link t;
	if(id==key){
		printf("node %d: parent = %d, depth = %d, ",key,p,d);
		if(a[id]==NULL)printf("leaf, [");
		else if(p==-1)printf("root, [");
		else printf("internal node, [");
		for(t=a[id];t!=NULL;t=t->next){
			if(t->next==NULL)break;
			printf("%d, ",t->v);
		}
		if(t==NULL)printf("]\n");
		else printf("%d]\n",t->v);
	}
	
	for(t=a[id];t!=NULL;t=t->next){
		search(key,t->v,a,id,d+1);
	}
}


int main(void){
	link a[SIZE];
	int visit[SIZE];
	int i,j;
	int n,id,k,c;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&id);
		a[id]=NULL;
		visit[id]=0;
		scanf("%d",&k);
		for(j=0;j<k;j++){
			scanf("%d",&c);
			a[id]=NEW(c,a[id]);
		}
	}
	int head;
	for(i=0;i<n;i++){
		searchHead(visit,i,a);
		if(check(visit,n)==1){
			head=i;
			break;
		}
	}
	
	for(i=0;i<n;i++){
		search(i,head,a,-1,0);
	}
	
	
	return 0;
}