ICPC 2007 Asia Region, Problem B