Completed http://poj.org/problem?id=1922