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

struct Node{ int p, l, r, depth;};
struct Node T[MAX];

int flag,k;

void maketree(int id, int c){
  T[c].p = id;
  if(flag == 0) T[id].l = c;
  else if(flag == 1) T[T[id].l].r = c;
  else if(flag == 2)T[T[T[id].l].r].r = c;
  T[c].depth = T[id].depth + 1;
}

void print(int u){
  if(T[u].p == -1){
    if(T[u].l == -1) printf("node %d: parent = %d, depth = %d, root, []", u, T[u].p, T[u].depth);
    else if(T[u].l != -1 && T[T[u].l].r == -1) printf("node %d: parent = %d, depth = %d, root, [%d]", u, T[u].p, T[u].depth, T[u].l);
    else if(T[u].l != -1 && T[T[u].l].r != -1 && T[T[T[u].l].r].r == -1) printf("node %d: parent = %d, depth = %d, root, [%d, %d]", u, T[u].p, T[u].depth, T[u].l, T[T[u].l].r);
    else if(T[u].l != -1 && T[T[u].l].r != -1 && T[T[T[u].l].r].r != -1) printf("node %d: parent = %d, depth = %d, root, [%d, %d, %d]", u, T[u].p, T[u].depth, T[u].l, T[T[u].l].r, T[T[T[u].l].r].r);
  }
  else{
    if(T[u].l == -1) printf("node %d: parent = %d, depth = %d, leaf, []", u, T[u].p, T[u].depth);
    else if(T[u].l != -1 && T[T[u].l].r == -1) printf("node %d: parent = %d, depth = %d, internal node, [%d]", u, T[u].p, T[u].depth, T[u].l);
    else if(T[u].l != -1 && T[T[u].l].r != -1 && T[T[T[u].l].r].r == -1) printf("node %d: parent = %d, depth = %d, internal node, [%d, %d]", u, T[u].p, T[u].depth, T[u].l, T[T[u].l].r);
    else if(T[u].l != -1 && T[T[u].l].r != -1 && T[T[T[u].l].r].r != -1) printf("node %d: parent = %d, depth = %d, internal node, [%d, %d, %d]", u, T[u].p, T[u].depth, T[u].l, T[T[u].l].r, T[T[T[u].l].r].r);
  }
}

int main(){
  int i, j, id, c, l, n;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r =NIL;
  }
  T[0].depth = 0;
  for ( i = 0; i < n; i++ ){
    scanf("%d%d", &id, &k);
    flag = 0;
    if(k != 0){
      for ( j = 0; j < k; j++ ){
	scanf("%d", &c);
	maketree(id, c);
	flag++;
      }
    }
  }
  for ( i = 0; i < n; i++ ){ 
    print(i);
    printf("\n");
  }
  return 0;
}