#include <stdio.h>
#define MAX 100005
#define NULL -1
typedef struct
{
	int p,l,r;	//???????????????????????? 
}Node;
Node T[MAX];
int depth;
void Depth(int i)
{
	if(T[i].p!=-1)
	{
		depth++;
		Depth(T[i].p);
	}	
}

void typenode(int i)
{
	if(T[i].p==-1)
	printf("root,[");
	else if(T[i].l==-1)	
	printf(" leaf, [");
	else
	printf("internal node,[");
}

void printchildren(int i)
{
	if(i==-1)
	printf("]\n");
	else if(T[i].r==-1)
	printf("%d]\n",i);
	else if(T[i].r!=-1)
	{
		printf("%d,",i);
		printchildren(T[i].r);
	}
}
int main(int argc, char *argv[])
{
	int n,i,j,node,children,sibling,count;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	T[i].p=T[i].l=T[i].r=NULL;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&node,&count);
		for(j=0;j<count;j++)	
		{
			scanf("%d",&children);
			if(j==0)
			{
				T[i].l=children;
				T[children].p=node;
			}
			else
			{
				T[sibling].r=children;
				T[children].p=node;
			}
			sibling=children;			
		}		
	}
	for(i=0;i<n;i++)
	{
		depth=0;
		Depth(i);
		printf("node %d: parent=%d, depth=%d,",i,T[i].p,depth);
		typenode(i);
		printchildren(T[i].l);	
	}
	return 0;
}