x = gets.to_i f = (0..x).map{|i| i-1 } 2.upto(x) do |i| i.step(x, i){|j| f[j] -= 1 } end p = [] * (x/2).ceil 1.upto(x/2) do |a| b = x - a score = (f[a]-f[b]).abs p[score] ||= [] p[score] << a p[score] << b if b != a end ans = p.find{|pi| !pi.nil? } ans.sort.each{|a| puts "#{a} #{x-a}" }