http://www.spoj.com/problems/SNGMSG/