#include<stdio.h>
#define N 100000

struct Node{
  int p,l,r;
};
struct Node T[N+1];
int main()
{
  int n,k,c,l=0,i,j,m,p;

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

  for(p=0;p<n;p++){
    printf("node %d: parent = %d, ",p,T[p].p);
    m = T[p].p;
    j=0;
    while(1){
      if(m == -1)break;
      else {
        m = T[m].p;
        j++;
      }
    }
    printf("depth = %d, ",j);
    if(T[p].p == -1){
      printf("root, [");
    }
    else if(T[p].l == -1){
      printf("leaf, [");
    }
    else printf("internal node, [");
    
    if(T[p].l != -1){
      printf("%d",T[p].l);
      i=T[p].l;
      while(1){
        if(T[i].r == -1)break;
        else {
	  printf(", %d",T[i].r);
          i = T[i].r;
	}
      }
    }
    printf("]\n");
  }
  return 0;
}
    