ICPC 2009 Asia Region, Problem B