A sloppy implementation of MSO's lab III assignment.