#include<stdio.h>
#define F 999999999

struct Tree
{
  int key; //key
  int p; //parent
  int l; //left
  int r; //right 
};

struct Tree A[250];

int main()
{
  int N;
  int i;
  
  scanf("%d",&N);
  N++;

  for(i=1;i<N;i++)
    {
      A[i].key = A[i].p = A[i].l = A[i].r = F;
    }
  scanf("%d",&A[1].key);
  for(i=2;i<N;i++)
    {
      scanf("%d",&A[i].key);
      if(i%2==1)
	{
	  A[i].p=A[i/2].key;
	  A[i/2].r=A[i].key;
	}
      else if(i%2==0)
	{
	  A[i].p=A[i/2].key;
	  A[i/2].l=A[i].key;
	}
	
    }

  for(i=1;i<N;i++)
    {
      if(i==1)
	printf("node 1: key = %d, left key = %d, right key = %d, \n",A[i].key,A[i].l,A[i].r);
      else if(A[i].l!=F && A[i].r!=F)
	printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,A[i].key,A[i].p,A[i].l,A[i].r);
      else if(A[i].l==F) 
	printf("node %d: key = %d, parent key = %d, \n",i,A[i].key,A[i].p);
      else if(A[i].r==F)
	printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,A[i].key,A[i].p,A[i].l);
    }



  return 0;
  
}

