#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 10000

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

int n, D[MAX], H[MAX];
Node T[MAX];

void setDepth(int u, int d) {
	if (u == -1) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if (T[u].left != -1) h1 = setHeight(T[u].left) + 1;
	if (T[u].right != -1) h2 = setHeight(T[u].right) + 1;
	return H[u] = max(h1, h2);
}

int getSibling(int u) {
	if (T[u].p == -1) return -1;
	if (T[T[u].p].left != u && T[T[u].p].left != -1)
		return T[T[u].p].left;
	if (T[T[u].p].right != u && T[T[u].p].right != -1)
		return T[T[u].p].right;
	return -1;
}

void print(int u) {
	int deg = 0;
	if (T[u].left != -1) deg++;
	if (T[u].right != -1) deg++;
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",
		u, T[u].p, getSibling(u), deg, D[u], H[u]);
	if (T[u].p == -1) printf("root\n");
	else if (T[u].left == -1 && T[u].right == -1) printf("leaf\n");
	else printf("internal node\n");
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) T[i].p = -1;
	int id, left, right;
	for (int i = 0; i < n; ++i) {
		cin >> id >> left >> right;
		T[id].left = left;
		T[id].right = right;
		if (left != -1) T[left].p = id;
		if (right != -1) T[right].p = id;
	}
	int root;
	for (int i = 0; i < n; ++i)
		if (T[i].p == -1) root = i;
	setDepth(root, 0);
	setHeight(root);
	for (int i = 0; i < n; ++i) print(i);

	return 0;
}
