#include <iostream>
#include "bits/stdc++.h"
using namespace std;
using graph = vector<vector<int>>;
typedef long long ll;


int main() {
	ll n,id,kosu,mem,memb;
	cin >> n;
	vector<ll> parent(n, -1);
	vector<ll> left(n, -1);
	vector<ll> right(n, -1);

	for (int i = 0; i < n; i++) {
		cin >> id >> kosu;
		for (int j = 0; j < kosu; j++) {
			cin >> mem;
			if (j == 0) {
				left[id] = mem;
			}
			else{
				right[memb] = mem;
			}
			parent[mem] = id;
			memb = mem;
		}
	}


	int c,d,e;
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << parent[i] << ", depth = ";
		d = 0;
		e = i;
		while (e != -1) {
			e = parent[e];
			d++;
		}
		cout << d-1 << ", ";
		if (parent[i] == -1) {
			cout << "root, [";
		}
		else if (left[i] == -1) {
			cout << "leaf, [";
		}
		else {
			cout << "internal node, [";
		}

		c = left[i];
		while (c != -1) {
			cout << c;
			if (right[c] != -1) {
				cout << ", ";
			}
			c = right[c];
		}
		cout << "]" << endl;
	}
	return 0;
}
