Let $x be the amount invested at 8%, the rest being $31000-x.
After a year, the interests are 0.08x and 0.095(31000-x).
0.095(31000-x)-0.08x=582.50, 2945-0.095x-0.08x=582.50, 0.175x=2945-582.50=2362.50.
So x=2362.50/0.175=$13500, and 31000-13500=$17500.
$13500 at 8% and $17500 at 9½%.