http://uva.onlinejudge.org/external/109/10954.html