#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class RootedNode{
public:
	vector<ll> parent;
	ll depth,dist;
	RootedNode():depth(0),dist(0){}
};

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	map<int,int> input;
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		input[v]++;
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class RootedTree{
	int parent_size;

	void DFS(ConnectNodeInfo& connection,ll child,ll parent,ll dep,ll dist){
		node[child].parent[0] = parent;
		node[child].depth = dep;
		node[child].dist = dist;

		for(int i = 0;i < connection[child].size();i++){
			if(connection[child][i].first != parent){
				DFS(connection,connection[child][i].first,child,dep+1,dist+connection[child][i].second);
			}
		}
	}
public:
	vector<RootedNode> node;

	RootedTree(ConnectNodeInfo& connection,int root){
		auto connection_size = connection.size();
		parent_size = 1;
		while((1LL<<parent_size)<connection_size) parent_size++;

		node.resize(connection_size);
		for(auto& x:node) x.parent.resize(parent_size,-1);
		DFS(connection,root,-1,0,0);
		for(int k=0;k<parent_size-1;k++){
			for(int v=0,ev=connection_size;v<ev;v++){
				if(node[v].parent[k] < 0) node[v].parent[k+1] = -1;
				else node[v].parent[k+1] = node[node[v].parent[k]].parent[k];
			}
		}
	}
};

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

	int N=in();
	ConnectNodeInfo connect(N);
	REP(i,N){
		int u=in(),K=in();
		REP(i,K){
			int v=in();
			connect.AddDirectionalConnection(u,v,1);
		}
	}
	int root;
	REP(i,N){
		if(connect.input[i]==0){
			root = i;
			break;
		}
	}
	RootedTree tree(connect,root);

	REP(i,N){
		cout << "node " << i << ": parent = " << tree.node[i].parent[0] << ", depth = " << tree.node[i].depth;
		if(tree.node[i].depth==0){
			cout << ", root, [";
			for(int j=0,ej=connect[i].size();j<ej;j++){
				cout << connect[i][j].first;
				if(j<ej-1) cout << ", ";
			}
			out("]");
		}
		else if(connect[i].empty()) cout << ", leaf, []" << endl;
		else{
			cout << ", internal node, [";
			for(int j=0,ej=connect[i].size();j<ej;j++){
				cout << connect[i][j].first;
				if(j<ej-1) cout << ", ";
			}
			out("]");
		}
	}
	
	return 0;
}



Measured memory_bytes: 30416