#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

struct node {
	int id = 0;
	int l = -1;
	int r = -1;
	int parent = -1;
	int name = 0;
	int degree = 0;
	int depth = 0;
	int height = 0;
	int sibling = -1;
};

node a[25];

void soya(node b, int zero) {
	a[b.id].depth = zero;
	if (b.l != -1) {
		soya(a[b.l], zero + 1);
	}
	if (b.r != -1) {
		soya(a[b.r], zero + 1);
	}
}

int niri(node d) {
	int h1 = 0;
	int h2 = 0;
	if (d.l != -1) {
		h1 = niri(a[a[d.id].l]) + 1;
	}
	if (d.r != -1) {
		h2 = niri(a[a[d.id].r]) + 1;
	}
	a[d.id].height = d.height + max(h1,h2);
	return max(h1,h2);
}

int main()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		a[num].id = num;
		cin >> a[num].l;
		cin >> a[num].r;
		if (a[num].l != -1) {
			a[num].degree++;
			a[a[num].l].parent = num;
			a[a[num].l].sibling = a[num].r;
		}
		if (a[num].r != -1) {
			a[num].degree++;
			a[a[num].r].parent = num;
			a[a[num].r].sibling = a[num].l;
		}
		if (a[num].l == -1 && a[num].r == -1) {
			a[num].name = 1;
		}
	}
	int x = 0;
	for (int i = 0; i < n; i++) {
		if (a[i].parent == -1) {
			x = i;
			a[i].name = -1;
		}
	}

	soya(a[x], 0);
	int t = niri(a[x]);

	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << a[i].parent << ", sibling = " << a[i].sibling << ", degree = " << a[i].degree << ", depth = " << a[i].depth << ", height = " << a[i].height << ", ";
		if (a[i].name == -1) cout << "root" << endl;
		else if (a[i].name == 1) cout << "leaf" << endl;
		else cout << "internal node" << endl;
	}

	return 0;
}


