Kuhn algorithm solving http://imcs.dvfu.ru/cats/static/problem_text-cpid-935938.html