#define NMAX 100000
#include <stdio.h>

typedef struct {
  int parent;
  int type; // 0=root, 1=internal root, 2=leaf
  int children;
  int depth;
} node;

int main(int argc, char const *argv[]) {

  node nd[NMAX];
  int v,i,j,nnum,ctr;

  scanf("%d",&v);

  for (ctr = 0; ctr < v; ctr++) {
    nd[nnum].parent = -1;
  }


  //inputloop start
  for (ctr = 0; ctr < v; ctr++) {
    scanf("%d",&nnum);
//    nd[nnum].parent = -1;
//    nd[nnum].depth = 0;
    scanf("%d",&nd[nnum].children);

    for (i = 0; i < nd[nnum].children; i++) {
      scanf("%d",&j);
      nd[j].parent = nnum;
    }

  }
    //inputloop end
    for (i = 0; i < v; i++) {
      j = i;
      while(nd[j].parent != -1){
        j = nd[j].parent;
        nd[i].depth++;
      }
    }

  for (nnum = 0; nnum < v; nnum++) {
    printf("node %d: parent = %d, depth = %d, ",nnum,nd[nnum].parent,nd[nnum].depth);

    if (nd[nnum].children == 0) {
      printf("leaf, ");
    }
    else if (nd[nnum].parent == -1){
      printf("root, ");
    }
    else {
      printf("internal node, ");
    }
    printf("[");
    for (i = 0; i < v; i++) {
      if (nd[i].parent == nnum) {
        printf("%d, ",i);
      }
    }
    if (nd[nnum].children != 0) {
      printf("\b\b");
    }
    printf("]\n");
  }


  return 0;
}