South Dakota State holds off Montana State 31-27