def array_rotate(array, val)
  array.shift
  array.push(val)

  array
end

s = gets.chomp.to_f

max = 1_000_000_000
aa = b = nil

1.upto(s).each do |a|
  b = max
  b_min = 1
  b_max = max
  prev_b_list = Array.new(10)

  while prev_b_list.count(b.to_i) <= 2
    tmp = a * b.to_i
    if tmp == s
      aa = a
      break
    end

    array_rotate(prev_b_list, b.to_i)

    next_calc = tmp < s ? :+ : :-

    d = case next_calc
        when :+
          b_min = b
          b + (b_max - b).to_f.div(2)
        when :-
          b_max = b
          b - (b - b_min).to_f.div(2)
        end.abs

    puts "#{a}, #{b}"
    p prev_b_list
    b = b.send(next_calc, d)
    # binding.irb if prev_b_list.include?(b.to_i)
  end
end

puts "0 0 #{aa} 0 0 #{b}"
