while b = gets.to_i
    break if b == 0
    m = 1
    n = b
    (2..b).each do |k|
        break if (k + 1) * k / 2 > b
        x = b * 2
        next if x % k > 0
        x /= k
        x -= k - 1
        next if x < 2 || x.odd?
        m = k
        n = x / 2
    end
    puts "#{n} #{m}"
end
