#include <stdio.h>
#include <stdlib.h>

typedef struct
{
	int parent;
	int depth;
	int size;
	int *children;
} node;

void set_depth(node *data, int x, int d)
{
	data[x].depth = d;
	for(int i = 0; i < data[x].size; ++i)
	{
		set_depth(data, data[x].children[i], d+1);
	}
}

int main()
{
	int n;
	node data[100000];
	
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		data[i].parent = -1;
		data[i].depth  = -1;
	}
	
	for(int i = 0; i < n; ++i)
	{
		int x, k, c;
		scanf("%d %d", &x, &k);
		
		data[x].size = k;
		data[x].children = malloc(sizeof(int) * k);
		for(int j = 0; j < k; ++j)
		{
			scanf("%d", &c);
			data[x].children[j] = c;
			data[c].parent = x;
		}
	}
	
	for(int i = 0; i < n; ++i)
	{
		if(data[i].parent == -1)
		{
			set_depth(data, i, 0);
			break;
		}
	}
	
	for(int i = 0; i < n; ++i)
	{
		printf("node %d: parent = %d, depth = %d, ", i, data[i].parent, data[i].depth);
		
		if(data[i].parent == -1)
		{
			printf("root");
		}
		else if(data[i].size == 0)
		{
			printf("leaf");
		}
		else
		{
			printf("internal node");
		}
		
		printf(", [");
		for(int j = 0; j < data[i].size; ++j)
		{
			if(j != 0) { printf(", "); }
			printf("%d", data[i].children[j]);
		}
		printf("]\n");

		free(data[i].children);
	}
}

