Second attempt to solve UVa 507 problem
Merge branch 'kn_507'