A Montana judge came down hard on two defendants who faked military service, ordering them to handwrite the names of all Americans killed in action in Iraq and Afghanistan.

The unusual sentence was handed down by Cascade County District Judge Greg Pinski last week against Ryan Patrick Morris, 28, and Troy Allan Nelson, 33, NBC affiliate KTVH of Great Falls, Montana, reported.

The two men had falsely claimed military service in their bid to get into Veterans Treatment Court, a separate court in the state for veterans struggling with addiction or other health issues. The men allegedly believed they would get more lenient sentences in this court.

Instead, the judge sentenced Morris, convicted of burglary, to 10 years in prison with three of the years suspended, KTVH reported. Nelson got five years behind bars with two years suspended for criminal possession of dangerous drugs.

The judge also ordered that before the men are released they must write the names of 6,756 American service members killed in action in Iraq and Afghanistan. Department of Defense figures show about the same number, 6,638, military service personnel, killed in action in these conflicts.

Morris and Nelson were also ordered to handwrite obituaries for 40 Montanans killed in Iraq and Afghanistan and pen apology letters to the American Legion, AmVets, Disabled American Veterans, the Iraq and Afghanistan Veterans of America, the Veterans of Foreign Wars, and the Vietnam Veterans of America.

They will also have to perform 441 hours of community service, KTVH reported.