#include <stdio.h>

#define N_MAX 25

typedef struct _Node {
	int parent;
	int degree;
	int depth;
	int height;
	int kind;
	int left;
	int right;
} Node;

Node Tree[N_MAX];

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

int setting(int pos, int depth) {
	int lh, rh;
	Tree[pos].depth = depth;
	lh = rh = 0;
	if (Tree[pos].left != -1) lh = setting(Tree[pos].left, depth + 1);
	if (Tree[pos].right != -1) rh = setting(Tree[pos].right, depth + 1);
	Tree[pos].height = lh > rh ? lh : rh;
	if (Tree[pos].parent == -1) Tree[pos].kind = 0;
	else if (Tree[pos].degree == 0) Tree[pos].kind = 1;
	else Tree[pos].kind = 2;

	return Tree[pos].height + 1;
}

void dump(int n) {
	int i, sibling;
	Node *parent;
	for (i = 0; i < n; i++) {
		printf("node %d: ", i);
		printf("parent = %d, ", Tree[i].parent);
		sibling = Tree[i].parent == -1 ? -1
			: Tree[Tree[i].parent].left == i ? Tree[Tree[i].parent].right
			: Tree[Tree[i].parent].left;
		printf("sibling = %d, ", sibling);
		printf("degree = %d, ", Tree[i].degree);
		printf("depth = %d, ", Tree[i].depth);
	printf("height = %d, ", Tree[i].height);
		printf("%s\n", Kind[Tree[i].kind]);
	}
}

int main() {
	int i, n, pos;

	scanf("%d", &n);
	for (i = 0; i < n; i++) Tree[i].parent = -1;

	for (i = 0; i < n; i++) {
		scanf("%d", &pos);
		scanf("%d", &Tree[pos].left);
		scanf("%d", &Tree[pos].right);
		Tree[pos].degree = 0;
		if (Tree[pos].left != -1) {
			Tree[Tree[pos].left].parent = pos;
			Tree[pos].degree++;
		}
		if (Tree[pos].right != -1) {
			Tree[Tree[pos].right].parent = pos;
			Tree[pos].degree++;
		}
	}

	i = 0;
	while (Tree[i].parent != -1) i++;

	setting(i, 0);

	dump(n);

	return 0;
}
