#include <stdio.h>          // printf(), scanf()
#define MAX_N 100000

typedef struct node_tbl
{
	int parent;
	int left;
	int right;
} node;

const int nil = -1;
node t[MAX_N];
int d[MAX_N];

void
print(int u)
{
	int c;
	int i;

	printf("node %d: ", u);
	printf("parent = %d, ", t[u].parent);
	printf("depth = %d, ", d[u]);
	if (t[u].parent == nil)
		printf("root, [");

	else if (t[u].left == nil)
		printf("leaf, [");

	else
		printf("internal node, [");

	const char* sep = "";
	for (i = 0, c = t[u].left; c != nil; i++, c = t[c].right)
	{
		printf("%s%d", sep, c);
		sep = ", ";
	}

	printf("]\n");
}

void
rec(int u, int p)
{
	d[u] = p;
	if (t[u].right != nil)
		rec(t[u].right, p);

	if (t[u].left != nil)
		rec(t[u].left, p + 1);
}

int
main(int argc, char** argv)
{
	int n;
	int v;
	int c;
	int l, r;
	int i, j, k;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		t[i].parent = t[i].left = t[i].right = nil;

	for (i = 0; i < n; ++i)
	{
		scanf("%d %d", &v, &k);
		for (j = 0; j < k; ++j)
		{
			scanf("%d", &c);
			if (j == 0)
				t[v].left = c;
			else
				t[l].right = c;

			l = c;
			t[c].parent = v;
		}
	}

	for (i = 0; i < n; ++i)
	{
		if (t[i].parent == nil)
		{
			r = i;
			break;
		}
	}

	rec(r, 0);
	for (i = 0; i < n; ++i)
		print(i);

	return 0;
}