Solve for x qx+x=r