#include <stdio.h>

#define NODEMAX 100000

struct Node {
  int parent;
  int lchild;
  int rsib;
};
  
int main()
{
  int i, j, n, id, nchildren, lchildID, depth;

  struct Node T[NODEMAX];

  scanf("%d",&n);

  for(i = 0; i < n; i++) {
    T[i].parent = -1;
  }
  
  for(i = 0; i < n; i++) {
    scanf("%d%d",&id,&nchildren);   
    if(nchildren > 0) {
      scanf("%d",&lchildID);
      T[id].lchild = lchildID;
      T[lchildID].parent = id;
      for(j = 0; j < nchildren-1; j++) {
        scanf("%d",&T[lchildID].rsib);
        lchildID = T[lchildID].rsib;
	T[lchildID].parent = id;
      }
      T[lchildID].rsib = -1;
    }
    else T[id].lchild = -1;     
  }


  for(i = 0; i < n; i++) {
    depth = 0;
    id = i;
    while(T[id].parent >= 0) {
      id = T[id].parent;
      depth++;
    }
    printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, depth);
    if(T[i].parent < 0) printf("root, ");
    else if(T[i].lchild < 0) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    id = T[i].lchild;
    if(id >= 0)  {
      printf("%d",id);
      while(T[id].rsib >= 0) {
        id = T[id].rsib;
        printf(", %d",id);
      }
    }
    printf("]\n");
  }
  
  return 0;
}


