Solved exercise C of SWERC 2008.