require 'complex'

class Complex
    def conv
        if imag.abs > 10000
            'overflow'
        elsif real.abs > 10000
            'overflow'
        elsif imag == 0
            real
        elsif real == 0
            "#{image}i"
        else
            self
        end
    end
end

class Integer
    def conv
        abs > 10000 ? 'overflow' : self
    end
end

while gets
    puts eval($_.chomp.gsub(?i, "Complex(0,1)")).conv
end