Court rules state should pay for sex change of transgender prisoner