include Math

Point = Struct.new(:x, :y) do
  def to_s
    '%.8f %.8f' % [x, y]
  end
end

def koch(n, p1, p2)
  return if n == 0

  s_x = (2 * p1.x + 1 * p2.x) / 3.0
  s_y = (2 * p1.y + 1 * p2.y) / 3.0

  s = Point.new(s_x, s_y)

  t_x = (1 * p1.x + 2 * p2.x) / 3.0
  t_y = (1 * p1.y + 2 * p2.y) / 3.0

  t = Point.new(t_x, t_y)

  th = PI * 60.0 / 180.0

  u_x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x
  u_y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y

  u = Point.new(u_x, u_y)

  koch(n - 1, p1, s)
  puts s
  koch(n - 1, s, u)
  puts u
  koch(n - 1, u, t)
  puts t
  koch(n - 1, t, p2)
end

n = gets.to_i

p1 = Point.new(0.0, 0.0)
p2 = Point.new(100.0, 0.0)

puts p1
koch(n, p1, p2)
puts p2