
fun main(args:Array<String>):Unit {
    val constant = Regex("""(-?\d+)$""")
    val single = Regex("""(-?\d*)x[-\+$]""")
    val coefficient = listOf(constant, single) + (2..5).map{Regex("""(-?\d*)x\^""" + it.toString())}
    val str = readLine()!!.trim()
    val polynomial = Polynomial(coefficient.map{it.find(str)?.let{when(it.groupValues[1]){
        "", "-" -> it.groupValues[1] + "1"
        else -> it.groupValues[1]
    }.toInt()} ?: 0})
    for (c in -2000 .. 2000){
        if (polynomial[-c] == 0) print(if (c > 0) "(x+$c)" else "(x$c)")
    }
    println()
}
class Polynomial(private val mCoefficient:List<Int>){
    operator fun get(x:Int):Int {
        var variable = 1
        var res = 0
        for (c in mCoefficient){
            res += c * variable
            variable *= x
        }
        return res
    }

    override fun toString(): String {
        return "${mCoefficient[5]}x^5+${mCoefficient[4]}x^4+${mCoefficient[3]}x^3+${mCoefficient[2]}x^2+${mCoefficient[1]}x+${mCoefficient[0]}"
    }
}
