// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <cstdio>
#define NMAX 25
#define NIL -1

struct Node {
	int parent, left, right;
};

struct Node T[NMAX];

int getSibling(int i) {
	int j = T[i].parent;
	if (j == NIL) return -1; // case of root node
	else if ((T[j].left != NIL) && (T[j].left != i)) return T[j].left;
	else if ((T[j].right != NIL) && (T[j].right != i)) return T[j].right;
	else return -1;
}

int getDegree(int i) {
	int deg = 0;
	if (T[i].left != NIL) deg++;
	if (T[i].right != NIL) deg++;
	return deg;
}

int getDepth(int i) {
	int depth = 0;
	while (T[i].parent != NIL) {
		i = T[i].parent;
		depth++;
	}
	return depth;
}

int getHeight(int i) {
	int h1 = 0, h2 = 0;
	if (T[i].left != NIL) h1 = getHeight(T[i].left) + 1;
	if (T[i].right != NIL) h2 = getHeight(T[i].right) + 1;
	if (h1 > h2) return h1;
	else return h2;
}

void print(int n) {
	for (int i = 0; i < n; i++) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", \
			i, T[i].parent, getSibling(i), getDegree(i), getDepth(i), getHeight(i));
		// judge a kind of node;
		if (T[i].parent == NIL) printf("root");
		else if ((T[i].left != NIL) || (T[i].right != NIL)) printf("internal node");
		else printf("leaf");
		printf("\n");
	}
}

int main() {
	int n, idx, left, right;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) T[i].parent = NIL;
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &idx, &left, &right);
		T[idx].left = left;
		T[idx].right = right;
		T[left].parent = T[right].parent = idx;
	}
	print(n);

	return 0;
}
