#include<stdio.h>
#define MAX 100000
#define NIL -1

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

struct Node Three[MAX];

int getDepth(int K){
  int depth = 0;

  for(depth = 0; Three[K].p != NIL; depth++){
    K = Three[K].p;
  }
return depth;
}

main(){
  int i,j,n;
  int num,deg,child,l = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    Three[i].p = NIL;
    Three[i].l = NIL;
    Three[i].r = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&num,&deg);

    for(j = 0; j < deg; j++){
      scanf("%d",&child);
      if(j == 0) Three[num].l = child;
      l = child;
      Three[child].p = num;
    }
  }

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

    if(getDepth(i) == 0){
      printf(", root, [");
    }
    else if(Three[i].l == NIL){
      printf(", leaf, [");
    }
    else{
      printf(", internal node, [");
    }

    j = Three[i].l;

    while(j != NIL){
      printf("%d", j);
      j = Three[j].r;

      if(j != NIL){
	printf(", ");
      }
    }
    printf("]\n");
  }

  return 0;
}