Solves UVA 10550. Another variant of combination lock