#include<stdio.h>

#define MAX 100005
#define NIL -1

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

Node g_node[MAX];
int g_n, g_m[MAX];

void print(int);
void rec(int, int);

int main(){
  int i,j,d,v,c,l,r;

  scanf("%d",&g_n);

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

  for(i = 0; i < g_n; i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j = 0; j < d; j++){
      scanf("%d",&c);
      if(j == 0) g_node[v].l = c;
      else g_node[l].r = c;
      l = c;
      g_node[c].p = v;
    }
  }
  for(i = 0; i < g_n; i++){
    if(g_node[i].p == NIL) r = i;
  }

  rec(r, 0);

  for(i = 0; i < g_n; i++) print(i);

  return 0;
}

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

  printf("node %d: ",u);
  printf("parent = %d, ", g_node[u].p);
  printf("depth = %d, ",g_m[u]);

  if(g_node[u].p == NIL) printf("root, ");
  else if(g_node[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

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

void rec(int u, int p){
  g_m[u] = p;
  if(g_node[u].r != NIL) rec(g_node[u].r, p);
  if(g_node[u].l != NIL) rec(g_node[u].l, p + 1);
}

