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

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

typedef struct{
	int par;
	int dep;
	link x;
}tree;


link NEW(int v, link n){ 
	link x = malloc(sizeof(*x));
	x->v = v; x->next = n;
	return x;                    
}

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

void search(int v[],int id,tree a[],int p,int d){
	link t;
	v[id]=1;
	if(a[id].par<p)a[id].par=p;
	if(a[id].dep<d)a[id].dep=d;
	if(a[id].x==NULL)return;
	for(t=a[id].x;t!=NULL;t=t->next){
		search(v,t->v,a,id,d+1);
	}
}

void printList(link a){
	if(a==NULL)return;
	printList(a->next);
	if(a->next==NULL)printf("%d",a->v);
	else printf(", %d",a->v);
}

void printNode(int key,tree a[]){
	tree temp=a[key];
	printf("node %d: parent = %d, depth = %d, ",key,temp.par,temp.dep);
	if(temp.par==-1)printf("root, [");
	else if(temp.x==NULL)printf("leaf, [");
	else printf("internal node, [");
	printList(temp.x);
	printf("]\n");
}


int main(void){
	tree 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].x=NULL;
		a[id].par=-1;
		visit[id]=0;
		scanf("%d",&k);
		for(j=0;j<k;j++){
			scanf("%d",&c);
			a[id].x=NEW(c,a[id].x);
		}
	}
	
	for(i=0;i<n;i++){
		if(visit[i]==1)continue;
		search(visit,i,a,-1,0);
		if(check(visit,n)==1){
			break;
		}
	}
	
	for(i=0;i<n;i++){
		printNode(i,a);
	}
	return 0;
}