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

#define NIL -1
#define N 100000

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

Node T[N];

int getDepth(int id) {
	int depth = 1;

	if (T[id].parent == NIL) return 0;
	depth += getDepth(T[id].parent);
	return depth;
}

void printChild(int id) {
	if (id == NIL) return;
	if (T[id].right == NIL) {
		printf("%d",id);
		return;
	}
	printf("%d, ",id);
	printChild(T[id].right);
}

int main() {
	int i,j,n;
	int id,degree,child,tmp;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		T[i].parent = NIL;
		T[i].left = NIL;
		T[i].right = NIL;
	}

	for (i = 0; i < n; i++) {
		scanf("%d %d", &id, &degree);
		for (j = 0; j < degree; j++) {
			scanf("%d", &child);
			T[child].parent = id;
			if (j == 0) T[id].left = child;
			else T[tmp].right = child;
			tmp = child;
		}
	}

	for (i = 0; i < n; i++) {
		printf("node %d: parent = %d, depth = %d,",i,T[i].parent, getDepth(i));
		if (T[i].parent == NIL) printf(" root,");
		else if (T[i].left != NIL) printf(" internal node,");
		else printf(" leaf,");
		printf(" [");
		printChild(T[i].left);
		printf("]\n");
	}

	return 0;
}