n = gets.to_i
rot = ->(v, θ) {
  t = θ / 180.0 * PI
  Matrix[[cos(t), -sin(t)], [sin(t), cos(t)]] * v
}
result = []

koch_curve = ->(p1, p2, level) {
  if level == n
    result << p1
    result << p2
  else
    l1 = (p2 - p1) / 3
    l2 = rot.(l1, 60)
    koch_curve.(p1, p3 = p1 + l1, level + 1)
    koch_curve.(p3, p4 = p3 + l2, level + 1)
    koch_curve.(p4, p5 = p3 + l1, level + 1)
    koch_curve.(p5, p2, level + 1)
  end
}

koch_curve.(Vector[0.0, 0.0], Vector[100.0, 0.0], 0)
([result[0]] + result + [result[-1]]).each_slice(2) {|a, _| puts "#{a[0]} #{a[1]}"}
