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

typedef struct Node {
	int id;
	int parent;
	int depth;
	int c;
	int *children;
	char type[20];
} Node;

void rec(Node *nodes, int root, int d) {
	nodes[root].depth = d;
	for (size_t i = 0; i < nodes[root].c; i++)
	{
		rec(nodes, nodes[root].children[i], d + 1);
	}
}

int main() {
	int n;
	scanf("%d", &n);
	Node *nodes = (Node *)calloc(n, sizeof(Node));
	for (size_t i = 0; i < n; i++)
	{
		nodes[i].parent = -1;
		nodes[i].children = NULL;
		nodes[i].depth = 0;
	}
	for (int t = 0; t < n; t++)
	{
		int i;
		scanf("%d", &i);
		// nodes[i].id
		scanf("%d", &nodes[i].c);
		nodes[i].children = (int *)calloc(nodes[i].c, sizeof(int));
		for (int j = 0; j < nodes[i].c; j++)
		{
			int nid;
			scanf("%d", &nid);
			nodes[i].children[j] = nid;
			nodes[nid].parent = i;
			// printf("i: %d j: %d input: %d\n",i, j, nid);

		}
		// printf("%d input\n", i);
	}
	// puts("after input");
	for (size_t i = 0; i < n; i++)
	{
		int r;
		if(nodes[i].parent == -1) {
			strcpy(nodes[i].type, "root");
			r = i;
		} else if(nodes[i].c == 0) {
			strcpy(nodes[i].type, "leaf");
		} else {
			strcpy(nodes[i].type, "internal node");
		}
		rec(nodes, r, 0);
	}

	for (int i = 0; i < n; i++)
	{
		printf("node %d: parent = %d, depth = %d, %s, ", i, nodes[i].parent, nodes[i].depth, nodes[i].type);
		printf("[");
		for (size_t j = 0; j < nodes[i].c; j++)
		{
			if(j == 0) {
				printf("%d", nodes[i].children[j]);
			} else {
				printf(", %d", nodes[i].children[j]);
			}
		}
		printf("]\n");
	}
}


