def koch_curve(z1, z2)
  [(z1*2+z2)/3.0,
   (Math.sqrt(3)/6.0)*(z1-z2)*1i + (z1+z2)/2.0,
   (z1+z2*2)/3.0]
end

def solve(z1, z2, n)
  if n == 0
    puts "#{z1.imag} #{z1.real}"
    return
  end
  new_z1, new_z2, new_z3 = koch_curve(z1, z2)
  solve(z1, new_z1, n-1)
  solve(new_z1, new_z2, n-1)
  solve(new_z2, new_z3, n-1)
  solve(new_z3, z2, n-1)
end

z1 = Complex(0, 0)
z2 = Complex(0, 100)
solve(z1, z2, gets.to_i)
puts "#{z2.imag} #{z2.real}"

