Africa Cup of Nations debutants Cape Verde have qualified for the knockout stages thanks to a 2-1 win over Angola.
Lucio Antunes's men fell behind in the 33rd minute of the game when Nando turned Amaro's cross beyond Josimar Diaz Vozinha.
They were unlucky to be going into the break trailing, and continued to push forward in search of an equaliser in the second half.
It looked as if they might be heading out of the tournament until Toni Varela's 81st-minute header restored parity, but Morocco's goal against South Africa saw them heading through.
However, Heldon picked up the pieces after Luis Lama had parried Julio Tavares's effort into his path and fired into the top corner in injury time to seal his country's progression.
No Data Analysis info