#include<stdio.h>

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

struct Node T[100000];
int n;
int D[100000];

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

int main(){
  int i,j,d,v,c,l,r;

  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = -1;
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&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;
  }
  deper(r,0);

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

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

    printf("[");

    for( h=0,m=T[i].l ; m!=-1 ; h++, m=T[m].r ){
      if(h) printf(", ");
      printf("%d",m);
    }
    printf("]\n");
  }
  return 0;
}

