Prisoners lose legal bid for voting rights