#include <stdio.h>

typedef struct{
  int p;
  int l;
  int r;
}Tree;

Tree T[100005];
int n, D[100005];

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

int main(){
  int i,j,k,d,v,c,l,r,n,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
    T[i].l=-1;
    T[i].r=-1;
  }
  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==-1)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==-1)printf("root, [");
    else if(T[i].l==-1)printf("leaf, [");
    else printf("internal node, [");
    for(k=0,a=T[i].l; a!=-1;k++, a=T[a].r){
      if(k)printf(", ");
      printf("%d", a);
    }
    printf("]\n");
  }
  return 0;
}