#include<stdio.h>

struct Tree {
  int id;
  int k;
  int c[20];
  int parent;
  int depth;
};

int main()
{

  int n, i, j, flag, k;
  struct Tree data[100], temp;


/* 入力 */
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d%d", &data[i].id, &data[i].k);
    for(j = 0; j < data[i].k; j++){
      scanf("%d", &data[i].c[j]);
    }
  }

/* parent判定 */
  for(i = 0; i < n; i++){
    for(j = 0; j < data[i].k; j++){
      for(k = 0; k < n; k++){
	if(i == 0) data[i].parent = -1;
	if(data[i].c[j] == data[k].id) data[k].parent = data[i].id;
      }
    }
  }

  flag = 1;
  j = 0;
  while(flag){
    flag = 0;
    for(i = n-1; i >= 1; i--){
      if(data[i].id < data[i-1].id){
	temp = data[i-1];
	data[i-1] = data[i];
	data[i] = temp;
	flag = 1;
	j++;
      }
    }
  }

/* 出力 */
  for(i = 0; i < n; i++){
    printf("node %d: ", data[i].id);
    printf("parent = %d, ", data[i].parent);

    /* printf("depth = %d, ", data[i].depth); */

    printf("[");
    for(j = 0; j < data[i].k; j++){
      if(j == 0) printf("%d", data[i].c[j]);
      else printf(", %d", data[i].c[j]);
    }
    printf("]\n");
    /* printf("\n"); */
  }

  return 0;
}