#include <stdio.h>
#define N 100000
struct Node{
  int p,l,r;
};
int n,id,k[N],c[N][20];
struct Node T[N];

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

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

  return 0;
}