#include<stdio.h>
#define N 1000000
#define M -1

typedef struct { int p, l, r; }Node;
Node Tree[N];
int A[N];

int rec(int u,int p) {
	A[u] = p;
	if (Tree[u].r != M) {
		rec(Tree[u].r, p);
	}
	if (Tree[u].l != M) {
		rec(Tree[u].l, p+1);
	}
}
int main(void) {
	int i, j, n,v,d, c, l, r,a=0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		Tree[i].p = M;
		Tree[i].r = M;
		Tree[i].l = M;
	}
	for (i = 0; i < n; i++) {
		scanf("%d%d", &v, &d);
		for (j = 0; j < d; j++) {
			scanf("%d", &c);
			if (j == 0) {
				Tree[v].l = c;
			}
			else {
				Tree[l].r = c;
			}
			l = c;
			Tree[c].p = v;
		}
	}
	for (i= 0; i < n; i++) {
		if (Tree[i].p == M) {
			r = i;
		}
	}
	rec(r, 0);
	for (i = 0; i < n; i++) {
		printf("node %d: parent = %d, depth = %d, ",i, Tree[i].p, A[i]);
		if (Tree[i].p == M) {
			printf("root, ");
		}
		else if (Tree[i].l == M) {
			printf("leaf, ");
		}
		else {
			printf("internal node, ");
		}

		a = Tree[i].l;
		printf("[");
		for (j = 0; a != M; j++, a = Tree[a].r) {
			if (j) {
				printf(", ");
			}
			printf("%d", a);
		}
		printf("]\n");
	}
	return 0;
}
