(n,),a=$<.map{|l|l.split.map &:to_i}
a=[i=0]+a
puts a.map{|v|s=*"node %d:"
d=i,v
i>1&&(s<<:parent
d<<a[i/2])
j=2*i
n>=j&&(s<<:left
d<<a[j])
n>j&&(s<<:right
d<<a[j+1])
s<<p
i+=1
s*" key = %d, "%d}[1,$$]