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

typedef struct{

	int id;
	int p;
	int d;
	int k;
	char type[20];
	int c[20];
}node;

node no[N];

int main()
{
	int i,j,n,l=0,m;
  
	while(1)
	{
		scanf("%d",&n);
		if(n >= 1 && n <= N) break;
	}

	for(i = 0;i < n; i++)
	{
		scanf("%d%d",&no[i].id,&no[i].k);
		for(j = 0; j < no[i].k; j++) scanf("%d",&no[i].c[j]);
	}


	while(l<n)
	{
		if(no[l].k != 0)
		{
			no[l].p = -1;
			no[l].d = 0;
			strcpy(no[l].type,"root");
			break;
		}
		l++;
	}
	
	if(l == n && n == 1)
	{
		no[0].p = -1;
		no[0].d = 0;
		strcpy(no[0].type,"root");	
	}	
	else
	{
		for(i=0;i<n;i++)
		{
			if(i == l && n != 1) i++;
		
			if(no[i].k != 0) strcpy(no[i].type,"internal node");
			else strcpy(no[i].type,"leaf");
		}

		for(i = 0; i < n; i++)
		{
			if(i == l && n != 1) i++;
			for(j = 0; j < n; j++)
				for(m = 0; m < no[j].k; m++)
			if(no[i].id == no[j].c[m]) no[i].p = no[j].id;
		}

		for(i = 0; i < n; i++)
		{
			if(i == l) i++;
			if(no[i].p != -1) no[i].d = no[no[i].p].d + 1;
		}	
	
	}
	for(i = 0; i < n; i++)
	{
		printf("node %d: parent = %d, depth = %d, %s, [",no[i].id,no[i].p,no[i].d,no[i].type);
		if(no[i].k == 0) printf("]\n");
		else
		{
			for(j = 0; j < no[i].k - 1; j++) printf("%d, ",no[i].c[j]);
			printf("%d]\n",no[i].c[j]);
		}
	}

 	 return 0;
}
