// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=jp

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

#define MAX_V 100000

vector<int> g[MAX_V];
int depth[MAX_V], parent[MAX_V];

void dfs(int u, int p, int d) {
	depth[u] = d;
	parent[u] = p;
	for (auto v : g[u]) {
		dfs(v, u, d + 1);
	}
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<bool> used(n, false);
	for (int i = 0; i < n; ++i) {
		int id; cin >> id;
		int k; cin >> k;
		while (k--) {
			int c; cin >> c;
			used[c] = true;
			g[id].push_back(c);
		}
	}

	int root = -1; {
		for (int i = 0; i < n; ++i) {
			if (not used[i]) root = i;
		}
		assert(root != -1);
	}

	dfs(root, -1, 0);
	for (int i = 0; i < n; ++i) {
		printf("node %d: parent = %d, depth = %d, ", i, parent[i], depth[i]);
		if (i == root) printf("root");
		else if (g[i].size() == 0) printf("leaf");
		else printf("internal node");
		printf(", [");
		for (int j = 0; j < g[i].size(); ++j) {
			printf("%d%s", g[i][j], ((j != g[i].size() - 1) ? ", " : ""));
		}
		printf("]\n");
	}
	return 0;
}

