#include<bits/stdc++.h>
using namespace std;

struct ans {
	int p, s, deg, dep;
};
ans a[30];
int id, r[30], l[30];
int h[30];


void sedep(int i,int depth) {
	a[i].dep = depth;
	depth++;
	if (r[i] != -1) {
		sedep(r[i], depth);
	}
	if (l[i] != -1) {
		sedep(l[i], depth);
	}
}

void sehi(int i, int hight) {
	h[i] = max(h[i], hight);
	hight++;
	if (a[i].p != -1) sehi(a[i].p, hight);
}

void print(int i) {
	cout << "node " << i << ": parent = " << a[i].p << ", sibling = " << a[i].s << ", degree = ";
	cout << a[i].deg << ", depth = " << a[i].dep << ", height = " << h[i] << ", ";
	if (a[i].p == -1)cout << "root";
	else if (h[i] != 0)cout << "internal node";
	else cout << "leaf";
	cout << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N; cin >> N;

	bool z[30];
	fill(z, z + N, false);
	fill(h, h + N, 0);
	
	
	for (int i = 0; i < N; i++) {
		cin >> id;
		cin >> l[id] >> r[id];
		int c = 0;
		a[l[id]].s = r[id];
		a[r[id]].s = l[id];
		if (l[id] != -1) {
			a[l[id]].p = id;
			c++;
			z[l[id]] = true;
		}
		if (r[id] != -1) {
			a[r[id]].p = id;
			c++;
			z[r[id]] = true;
		}
		a[id].deg = c;
	}
	
	int ro;
	for (int i = 0; i < N; i++) {
		if (z[i] == false) {
			a[i].p = -1;
			a[i].s = -1;
			ro = i;
			break;
		}
	}
	sedep(ro, 0);

	for (int i = 0; i < N; i++) {
		if (a[i].deg == 0) {
			sehi(i, 0);
		}
	}

	for (int i = 0; i < N; i++) {
		print(i);
	}
}
