#include<iostream>
using namespace std;
#define NIL -1
int n,D[100005];
struct zs{int id;int l;int r;}a[100000+2];
void printfs(int u)
{
    cout<<"node "<< u <<": ";
    cout<<"parent = "<<a[u].id <<", ";
    cout<<"depth = "<<D[u] <<", ";
    if(a[u].id==NIL)cout<<"root, ";
    else if(a[u].l==NIL)cout<<"leaf, ";
    else cout<<"internal node, ";
    cout<<"[";
    for(int i=0,c=a[u].l;c!=NIL;i++,c=a[c].r)
    {
        if(i)cout<<", ";
        cout<<c;
    }
    cout<<"]"<<endl;
}
void sd(int p,int u)
{
    D[p]=u;
    if(a[p].r!=NIL)sd(a[p].r,u);
    if(a[p].l!=NIL)sd(a[p].l,u+1);
}
int main()
{
    int i,j,d,c,r,v,l;
   cin>>n;
   for(i=0;i<n;i++)a[i].id=a[i].l=a[i].r=NIL;
   for(i=0;i<n;i++)
   {
       cin>>v>>d;
       for(j=0;j<d;j++)
       {
           cin>>c;
           if(j==0)a[v].l=c;
           else a[l].r=c;
           l=c;
           a[c].id=v;
       }
   }
   for(i=0;i<n;i++)if(a[i].id==NIL)r=i;
   sd(r,0);
   for(i=0;i<n;i++)printfs(i);
   return 0;
}