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

struct Node
{
int x, y, z;
};
struct Node A1[MAX];

int num, G, A2[MAX];

int getDepth(int m){
  int b = 0;
  for(; A1[m].x != NIL ;b++) m = A1[m].x;
  return b;
}

void print(int m){
  int i, c;
  printf("node %d: ", m);
  printf("parent = %d, ", A1[m].x);
  printf("depth = %d, ", A2[m]);

  if ( A1[m].x == NIL ) printf("root, ");
  else if ( A1[m].y == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = A1[m].y; c != NIL; i++, c = A1[c].z){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

int main(){
  int i, j, a, b, c, y;
  scanf("%d", &num);
  for ( i = 0; i < num; i++ ) A1[i].x = A1[i].y = A1[i].z = NIL;

  for ( i = 0; i < num; i++ ){
    scanf("%d %d", &a, &b);
    for ( j = 0; j < b; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) A1[a].y = c;
      else A1[y].z = c;
      y = c;
      A1[c].x = a;
    }
  }

  G = 0;
  for ( i = 0; i < num; i++ ){
    A2[i] = getDepth(i);
    if ( A2[i] > G ) G = A2[i];
  }

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

  return 0;
}