V4

This version finally works. It might take a little bit more time than
the first version (but it still find the solution in about 2-3sec). Also
it can be extended to more levels of productivity)