A, B, C, D, P, Q = gets.split.map(&:to_i) def f(x) A * x ** 3 + B * x ** 2 + C * x + D end ans = [-Float::INFINITY, 0, Float::INFINITY, 0] (P..Q).each do |x| h = f(x) if ans[0] < h ans[0] = h ans[1] = x end if ans[2] > h ans[2] = h ans[3] = x end end puts ans.join(' ')