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

int D[MAX];

struct Node {int parent, left, right;} T[MAX];

void setDepth(int u, int p) //節点u及びその部分木の各節点の深さをセット
{
  D[u] = p;
  if (T[u].right != NIL) setDepth(T[u].right, p);
  if (T[u].left != NIL) setDepth(T[u].left, p+1);
}

void print(int u)
{
  printf("node %d: parent = %d, depth = %d, ", u, T[u].parent, D[u]);
  
  if (T[u].parent == NIL) printf("root, [");
  else if (T[u].left == NIL) printf("leaf, [");
  else printf("internal node, [");
  
  for (int i = 0, c = T[u].left; c != NIL; i++, c = T[c].right) {
    if (i) printf(", ");
    printf("%d", c);
  }
  
  puts("]");
}

int main(void)
{
  int n, id, k, c, l, root;
  
  scanf("%d", &n);
  
  for (int i = 0; i < n; i++)
    T[i].parent = T[i].left = T[i].right = NIL;
  
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &id, &k);
    for (int j = 0; j < k; j++) {
      scanf("%d", &c);
      T[c].parent = id;
      if (j == 0)
        T[id].left = c;
      else
        T[l].right = c;
      l = c;
    }
  }
  
  for (int i = 0; i < n; i++)
    if (T[i].parent == NIL)
      root = i;
  
  setDepth(root, 0);
  
  for (int i = 0; i < n; i++)
    print(i);
  
  return 0;
}
