#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100000
#define NIL -1

typedef struct
{
  int parent;
  int left;
  int right;
}Node;

Node T[MAX];
int D[MAX];
int n;

void print(int u)
{
  int i, c;

  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, ");

  printf("[");
  for(i = 0, c = T[u].left; c != NIL; i++, c = T[c].right){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

int depth(int u, int p)
{
  D[u] = p;

  if(T[u].right != NIL) depth(T[u].right, p);
  if(T[u].left != NIL)  depth(T[u].left, p + 1);
}

int main(void)
{
  int a, b, c, l, r, i, j;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d %d", &a, &b);
    for(j = 0; j < b; j++){
      scanf("%d", &c);
      if(j == 0){
        T[a].left = c;
      }
      else{
        T[l].right = c;
      }
        l = c;
        T[c].parent = a;
    }
  }
  for(i = 0; i < n; i++){
    if(T[i].parent == NIL){
      r = i;
    }
  }

  depth(r, 0);

  for(i = 0; i < n; i++){
    print(i);
  }
  return 0;
}

