#include <iostream>
#include <stdlib.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u)
{
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";
	
	if(T[u].p == NIL) cout << "root, ";
	else if(T[u].l == NIL) cout << "leaf, ";
	else cout << "internal node, ";
	
	
	cout << "[";
	
	if(T[u].l != NIL)
	{
		cout << T[u].l;
		c = T[u].l;
		while(T[c].r != NIL)
		{
			cout << ", ";
			cout << T[c].r;
			c = T[c].r;
		}
	}
	
	cout << "]" << endl;
}

void rec(int u, int p)
{
	D[u] = p;
	if(T[u].r != NIL) rec(T[u].r, p);
	if(T[u].l != NIL) rec(T[u].l, p + 1); 
}


int main() {
	int i, j, v, d, t, c, root;
	cin >> n;
	for(i = 0; i < n; i++)
	{
		T[i].p = T[i].l = T[i].r = NIL;
	}
	
	for(i = 0; i < n; i++)
	{
		cin >> v >> d;
		for(j = 0; j < d; j++)
		{
			cin >> c;
			if(j == 0) T[v].l = c;
			else T[t].r = c;
			t = c;
			T[c].p = v; 
		}
	}
	
	for(i = 0; i < n; i++)
	{
		if(T[i].p == NIL) root = i;
	}
	
	rec(root, 0);
	
	for(i = 0; i < n; i++) print(i);
	
//	system("pause");
	return 0;
}
