Solved problem "Apocalypse soon" (APAC Semifinal 2008).