#include<stdio.h>
#define MAX 100001
#define N -1

void maketree(int,int);
void print(int);

struct Node{ 
  int p, l/*葉があることの確認*/, r/*右側にある数*/, depth;
};
struct Node T[MAX];

int flag,k,leaf;
 
int main(){
  int i, j, id, c/*葉を入れる変数*/, n, parent;
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r =N;
  }
  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++ ){
    parent = T[i].p;
    while(1){                 /* rootに到り付くまで、depthをインクリメントさせる。*/
      if(parent == -1) break;
      parent = T[parent].p;
      T[i].depth++;
    }
    print(i);
    printf("\n");
  }
  return 0;
}

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

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