#include<stdio.h>
#define MAX 9999999

int setchDepth(int u);
void print(int u);

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

struct Node T[MAX];
int n, k=0, Depth[MAX];

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", Depth[u]);

  if ( T[u].p == -1 ) printf("root, ");
  else if ( T[u].l == -1 ) printf("leaf, ");
  else printf("internal node, ");

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

int serchDepth(int u){
  int depth = 0;
  
  for(; T[u].p != -1;depth++){
    u = T[u].p;
  }
  
  return depth;
}


int main(){
  int i, j, k, sec, deg, ele;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &sec, &deg);
    for ( j = 0; j < deg; j++ ){
      scanf("%d", &ele);
      if ( j == 0 ) T[sec].l = ele;
      else T[k].r = ele;
      k = ele;
      T[ele].p = sec;
    }
  }

  for ( i = 0; i < n; i++ ){
    Depth[i] = serchDepth(i);
    
    if ( Depth[i] > k ) k = Depth[i];
  }

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

