#include<stdio.h>
#define NI NTL
#define H 250

int parent(int );
int left(int );
int right(int );

int P[H];
int main(){
  int n,i,p,left,right;
  scanf("%d", &n);
  for(i = 1;i<n;i++){
    scanf("%d" , &P[i]);
  }
  for(i = 1;i<=n;i++){
    printf("node %d: key = %d, ",i,P[i]);
    p = parent(i);
  if(p!=0){
    printf("parent key = %d", A[p]);
  }
  left = left(i);
  if(left <= n){
    printf("left key = %d, ", A[left]
}
 
      right = right(i);
    if(right <= n){
      printf("right key = %d, ",A[right]);
    }
    printf("\n");
  }
  return 0;
}
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}