answer to http://hihocoder.com/contest/ms1hour