A South Dakota man who pleaded guilty but mentally ill to three counts of first-degree murder was sentenced Tuesday to three consecutive life prison terms.

Ernest Tupper III, 58, appeared before Circuit Judge Glen Eng, who handed down the sentence.

Tupper shot and killed Robert Riibe, Chassidy Bamsey and Brian Van Wagner in September at a Yankton apartment.

His lawyer said Tupper's mental state involved an inability to tolerate contact with other people.

Several family members began to sob when Eng told Tupper his action affected hundreds of lives and that his mental condition was a reason but not an excuse.

Tupper, who also was ordered to pay $23,000 in restitution, was then shackled and led from the courtroom.