#complete_binary_tree
#ALDS1_9_A

class Node
  attr_accessor :key,:parent,:left,:right

  def initialize
    @parent = nil
    @left   = nil
    @right  = nil
  end

  def add_left(child)
      self.left    = child
      child.parent = self
  end

  def add_right(child)
      self.right    = child
      child.parent = self
  end

  def make_c_b_tree(n,all)
    if (2*n <= all)
      self.left = $nodes[2*n]
      self.left.make_c_b_tree(2*n,all)
      self.left.parent = self
    end
    if (2*n+1 <= all)
      self.right = $nodes[2*n+1];
      self.right.make_c_b_tree(2*n+1,all)
      self.right.parent = self
    end
  end
    
  def describe
    printf(" key = %d, ",self.key)
    printf("parent key = %d, ",self.parent.key) if self.parent != nil 
    printf("left key = %d, ",self.left.key)     if self.left != nil 
    printf("right key = %d, ",self.right.key)    if self.right != nil 
    printf("\n")
  end
end

class Complete_bin_tree
  attr_accessor :root

  def initialize
    @root = nil
  end

  def make(n)
    self.root = $nodes[1]
    self.root.make_c_b_tree(1,n);
  end
end


$c_b_tree = Complete_bin_tree.new
$n = STDIN.gets.split[0].to_i
$a =Array.new($n+1)
$nodes = Array.new($n+1){|i| Node.new}
s  = STDIN.gets.split

$c_b_tree.make($n)

0.upto($n-1){|i|
  $nodes[i+1].key = s[i] }

0.upto($n-1){|i|
  printf("node %d:",i+1)
  $nodes[i+1].describe }