http://uva.onlinejudge.org/external/106/10622.html