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

struct treetype {
	int parent;
	int depth;
	char type[20];
	int childcnt;
	int child[500];
};

int main(void) {
	int n;
	struct treetype tree[100213];
	int i, j, k;
	int number = 0;
	int roottr = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &number);
		scanf("%d", &tree[number].childcnt);

		if (tree[number].childcnt > 0) {		//子供の数設定
			for (j = 0; j < tree[number].childcnt; j++) {
				scanf("%d", &tree[number].child[j]);
				tree[tree[number].child[j]].parent = number;	//子供の親設定
			}
		}

	}

	for (i = 0; i < n; i++) {
		if (tree[i].parent == 0 && roottr == 0) {
			strcpy(tree[i].type, "root");
			tree[i].parent = -1;
			roottr = 1;
		}
		else if (tree[i].childcnt > 0) {
			strcpy(tree[i].type, "internal node");
		}
		else {
			strcpy(tree[i].type, "leaf");
		}
	}

	for (i = 0; i < n; i++) {
		k = i;
		for (j = 0; 1; j++) {
			if (tree[k].parent == -1) {
				tree[i].depth = j;
				break;
			}
			k = tree[k].parent;
		}
	}

	for (number = 0; number < n; number++) {
		printf("node %d: parent = %d, depth = %d, %s, [", number, tree[number].parent, tree[number].depth, tree[number].type);
		if (tree[number].childcnt > 0) {
			for (j = 0; j < tree[number].childcnt; j++) {
				printf("%d", tree[number].child[j]);
				if (j < tree[number].childcnt - 1) {
					printf(", ");
				}
			}
		}
		printf("]\n");
	}

	return 0;
}
