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

#define N_MAX 100000

const char Kind[3][14] = { "root","leaf","internal node" };

typedef struct _Node {
	int id;
	int parent;
	int depth;
	int kindId;
	int chldnum;
	int *chldtop;
} Node;

Node *A[N_MAX];

Node *allocNode() {
	Node *node = (Node*)malloc(sizeof(Node));
	node->chldnum = 0;
	node->chldtop = NULL;
	return node;
}

void setTree(Node *node, int parent, int depth) {
	int i;
	if (node == NULL) return;
	node->parent = parent;
	node->depth = depth;
	if (depth == 0) node->kindId = 0;
	else if (node->chldnum == 0) node->kindId = 1;
	else node->kindId = 2;

	for (i = 0; i < node->chldnum; i++) {
		setTree(A[*(node->chldtop + i)], node->id, depth + 1);
	}
}

void dump(int n) {
	int i, j;
	for (i = 0; i < n; i++) {
		printf("node %d: ", A[i]->id);
		printf("parent = %d, ", A[i]->parent);
		printf("depth = %d, ", A[i]->depth);
		printf("%s, ", Kind[A[i]->kindId]);
		printf("[");
		for (j = 0; j < A[i]->chldnum; j++) {
			if (j > 0) printf(", ");
			printf("%d",*(A[i]->chldtop+j));
		}
		printf("]\n");
	}	
}

void terminate(int n) {
	int i, j;
	for (i = 0; i < n; i++) {
		if (A[i]->chldnum > 0) free(A[i]->chldtop);
		free(A[i]);
	}
}

int main() {
	int i, j, n, first;
	Node *node;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		node = allocNode();
		scanf("%d", &(node->id));
		if (i == 0) first = node->id;
		scanf("%d", &(node->chldnum));
		if (node->chldnum > 0)
		{
			node->chldtop = (int*)malloc(sizeof(int) * node->chldnum);
			for (j = 0; j < node->chldnum; j++) {
				scanf("%d", node->chldtop + j);
			}
		}
		A[node->id] = node;
	}

	setTree(A[first],-1,0);

	dump(n);

	terminate(n);

	return 0;
}
