int tree(int);
void child(int);

int main()
{
  int i,j,n,k,id,c,d,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%d",&id,&k);
    for(j = 1; j <= k; k++){
      scanf("%d",&c);
      T[c].p = id;
      if(j == 1) T[id].l = c;
      else T[a].r = c;
      a = c;
    }
  }


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

    if(T[i].p == -1) printf("root, [");
    else if(T[i].l == -1) printf("leaf, [");
    else printf("internal node, [");

    child(i);
  }
  return 0;
}

int tree(int i){

  int d = 0;

  while(T[i].p != -1){
    i = T[i].p;
    d++;
  }
  return d;
}

void child(int i){

  int a;

  a = T[i].l;

  while(a != -1){
    printf("%d",a);
    a = T[a].r;
    if(a != -1) printf(", ");
  }
  printf("]");
}