#include <stdio.h>

#define NIL -1

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

struct Node t[100005];
int n,D[100005];

int 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,d,v,c,l,r;

  // printf("aaaaaaaa\n");
  
  scanf("%d",&n);
  for(i=0;i<n;i++)t[i].p=t[i].l=t[i].r = NIL;
  
  for(i=0;i<n;i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)t[v].l=c;
      else t[l].r=c;
      l=c;
      t[c].p=v;
    }
  }

  for(i=0;i<n;i++){
    if(t[i].p==NIL)r=i;
  }

  rec(r,0);
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,t[i].p,D[i]);

    if(t[i].p==NIL)printf("root, ");
    else if(t[i].l==NIL)printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(j=0,c=t[i].l;c != NIL;j++,c = t[c].r){
      if(j)printf(", ");
      printf("%d",c);
    }
    printf("]\n");
  }
  return 0;
}

