solved srm 589 div2 500 pt problem