But former AFCON champions Ghana suffered a shocking group-stage exit from the tournament that meant a real failure for the Black Stars.
The Senegalese team won Group B after a goalless draw with Malawi in Bafoussam, Cameroon.
They collected five points in three matches to top the group.
Earlier Tuesday, second-place Guinea reached the next stage, the round of 16, with four points in Group B.
Third-place Malawi have four points but should wait for a qualification chance.
The six group winners and runners-up (A to F), and four best third-placed teams will play in the AFCON round of 16.
Meanwhile in Group C, Morocco drew with Gabon 2-2 in Yaounde, but both teams qualified for the last 16.
Morocco won Group C with seven points while Gabon racked up five points to finish second.
Gabonese winger Jim Allevinah scored the opener in the 21st minute.
Morocco waited for the equalizer nearly an hour as Sofiane Boufal converted a penalty kick successfully in the 74th minute.
But Moroccan defender Nayef Aguerd scored an own goal in the 81st minute as Gabon took the lead again.
Three minutes later, Morocco's star Achraf Hakimi scored a classy freekick to secure a 2-2 draw.
- Former champions Ghana exit AFCON
Four-time AFCON champions Ghana were eliminated after a shocking 3-2 loss to Comoros in a Group C match in Garoua.
El Fardou Ben Nabouhane scored an early goal for Comoros.
Then Ghana were down to 10 men on the pitch as team captain Andre Ayew was shown a red card in the first half.
Ahmed Mogni doubled the gap in the 61st minute.
Ghana fought to make it 2-2 after the Black Stars' Richmond Boakye and Alexander Djiku scored.
In the 85th minute, Mogni netted the winning goal for Comoros, his second in the match.
So Ghana, with a point in three matches, returned home.
Third-place Comoros have three points in Group C and are a bit hopeful to extend their stay in Cameroon.