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

#define NIL -1

typedef struct _node {
	int parent;
	int child;
	int sibling;
} node;

node *allocNode() {
	node *p = (node *)malloc(sizeof(node));
	p->parent = NIL;
	p->child = NIL;
	p->sibling = NIL;
	return p;
}

void terminate(node **root, int n) {
	int i;
	for (i = 0; i < n; i++)	free(root[i]);
	free(root);
}

int countDepth(node **root, int cur) {
	int count, parent;
	count = 0;
	parent = root[cur]->parent;
	while (parent != NIL) {
		parent = root[parent]->parent;
		count++;
	}
	return count;
}

int getType(node *p) {
	if (p->parent == NIL) return 0;
	if (p->child != NIL) return 1;
	return 2;
}
int main() {
	int c, i, j, n, k, id, prev, child;
	node **root;
	char strtype[3][14] = {"root","internal node","leaf"};

	scanf("%d", &n);
	root = (node **)malloc(sizeof(node *) * n);
	for (i = 0; i < n; i++) root[i] = NULL;

	for (i = 0; i < n; i++) {
		scanf("%d %d", &id, &k);
		if (root[id] == NULL) root[id] = allocNode();
		for (j = 0; j < k; j++) {
			scanf("%d", &c);
			if (j == 0) root[id]->child = c;
			else root[prev]->sibling = c;
			root[c] = allocNode();
			root[c]->parent = id;
			prev = c;
		}
	}

	for (i = 0; i < n; i++) {
		printf("node %d: ", i);
		printf("parent = %d, ", root[i]->parent);
		printf("depth = %d, ", countDepth(root, i));
		printf("%s, ", strtype[getType(root[i])]);
		child = root[i]->child;
		printf("[");
		while (child != NIL) {
			printf("%d", child);
			child = root[child]->sibling;
			if (child != NIL) printf(", ");
		}
		printf("]\n");
	}

	terminate(root, n);
	return 0;
}
