http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1193