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

typedef struct node{
	int par_id;
	int depth;
	int childnum;
}node;

node a[N];

typedef struct list{
	int id;
	int flg;
	struct list *next;
}list;

list *L[N];

void insert(int x,int y){
	list *new=malloc(sizeof(list));
	new->id=y;
	new->flg=0;
	new->next=NULL;
	
	list **p=&L[x];
	while((*p)!=NULL)
		p=&((*p)->next);
	
	(*p)=new;
	
	return;
}

void print_child(int x,int childnum){
	list *p=L[x];
	int cnt=0;
	
	printf("[");
	
	while(p!=NULL){
		if(cnt==childnum-1)break;
		printf("%d, ",p->id);
		p=p->next;
		cnt++;
	}
	if(p!=NULL)
		printf("%d",p->id);
	
	printf("]\n");
	
	return;
}

void dfs(int i){
	if(a[i].par_id==-1)
		a[i].depth=0;
	
	list *p=L[i];
	while(p!=NULL){
		if(p->flg==0){
			p->flg=1;
			a[p->id].depth=a[i].depth+1;
			dfs(p->id);
		}
		p=p->next;
	}
	
	return;
}


int main(){
	int n,i,j,x,y;

	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		a[i].par_id=-1;
		a[i].depth=0;
		L[i]=NULL;
	}
	
	for(i=0;i<n;i++){
		scanf("%d",&x);
		scanf("%d",&a[x].childnum);
		for(j=0;j<a[x].childnum;j++){
			scanf("%d",&y);
			a[y].par_id=x;
			insert(x,y);
		}
	}
	
	for(i=0;i<n;i++){
		if(a[i].par_id==-1){
			dfs(i);
			break;
		}
	}
	
	for(i=0;i<n;i++){
		printf("node %d: ",i);
		printf("parent = %d, ",a[i].par_id);
		printf("depth = %d, ",a[i].depth);
		
		if(a[i].par_id==-1)
			printf("root, ");
		else if(a[i].childnum==0)
			printf("leaf, ");
		else 
			printf("internal node, ");
		
		print_child(i,a[i].childnum);
	}
	
	return 0;
	
}
