#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, id, lc[100009], rc[100009], deg[100009], p[100009], d[100009], s[100009], dp[100009]; bool vis[100009];
void rec(int pos) {
	vis[pos] = true;
	if (lc[pos] != -1) rec(lc[pos]);
	if (rc[pos] != -1) rec(rc[pos]);
}
void solve(int pos) {
	if (lc[pos] != -1) {
		d[lc[pos]] = d[pos] + 1;
		solve(lc[pos]);
		p[lc[pos]] = pos;
		s[lc[pos]] = rc[pos];
		dp[pos] = dp[lc[pos]] + 1;
	}
	if (rc[pos] != -1) {
		d[rc[pos]] = d[pos] + 1;
		solve(rc[pos]);
		p[rc[pos]] = pos;
		s[rc[pos]] = lc[pos];
		dp[pos] = max(dp[pos], dp[rc[pos]] + 1);
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &id);
		scanf("%d%d", &lc[id], &rc[id]);
	}
	int root = -1;
	for (int i = 0; i < n; i++) {
		if (!vis[i]) {
			rec(i);
			root = i;
		}
		if (lc[i] != -1) deg[i]++;
		if (rc[i] != -1) deg[i]++;
	}
	solve(root); p[root] = s[root] = -1;
	for (int i = 0; i < n; i++) {
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, p[i], s[i], deg[i], d[i], dp[i], (i == root ? "root" : (deg[i] ? "internal node" : "leaf")));
	}
	return 0;
}