#include<bits/stdc++.h>
using namespace std;
#define NIL -1
const int MAX=1e5+10;
struct Node{
    int p,l,r;//parent,left,right
    Node(int p=NIL,int l=NIL,int r=NIL){
        this->p=p;this->l=l;this->r=r;
    }
}T[MAX];
int n,D[MAX];//D是深度，O(n)递归求
void rec(int cur,int dep){
    D[cur]=dep;
    if(T[cur].l!=NIL) rec(T[cur].l,dep+1);
    if(T[cur].r!=NIL) rec(T[cur].r,dep);
}
void print(int cur){
    cout<<"node "<<cur<<": parent = "<<T[cur].p<<", "<<"depth = "<<D[cur]<<", ";
    if(T[cur].p==NIL) cout<<"root, [";
    else if(T[cur].l==NIL) cout<<"leaf, [";
    else cout<<"internal node, [";
    for(int i=0,c=T[cur].l;c!=NIL;c=T[c].r,i++){
        if(i) cout<<", ";
        cout<<c;
    }
    cout<<"]\n";
}
int main()
{
    int id,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>id>>k;
        int rr;
        for(int j=0;j<k;j++){
            cin>>v;
            if(j==0) T[id].l=v;
            else T[rr].r=v;
            rr=v;
            T[v].p=id;
        }
    }
    int root;
    for(int i=0;i<n;i++) if(T[i].p==NIL) {root=i;break;}//找根节点
    rec(root,0);
    for(int i=0;i<n;i++) print(i);
}

