Real Madrid came from behind to beat Union Berlin and reach the Champions League last 16 with a 100% record.
The hosts went ahead through Kevin Volland after goalkeeper Frederik Ronnow saved Luka Modric's penalty.
A win would have taken the Germans into the Europa League play-offs, but former Stoke and Newcastle striker Joselu scored two headers to put Real ahead.
Alex Kral's low shot made it 2-2, before Dani Ceballos finished from Jude Bellingham's pass for the winning goal.
Fourteen-time European champions Real won all six of their Group C matches to end with 18 points, eight more than second-placed Napoli who beat Braga 2-0.
This was Union Berlin's first campaign in the Champions League, but they finished bottom of the group with only two points to end their European involvement.
Real were awarded a 45th-minute penalty because of Diogo Leite's handball but Ronnow saved Modric's spot-kick, with the hosts going ahead shortly afterwards.
But they could not hang on as Joselu finished from crosses from Rodrygo and Fran Garcia to score twice in an 11-minute spell.
Kral made it 2-2 with five minutes left to give the home fans hope, only for Ceballos to score the last goal of the game in the 89th minute.
Reigning European champions Manchester City have already qualified and will also advance with a 100% record if they win at Red Star Belgrade on Wednesday in Group G.