Working PASTAB4 solution.