FR 3877 then FR 5686 at Madrid
Tangier → Madrid → Edinburgh
Timetable, Madrid time
17:35FR 3877 from Tangier at the gate
17:25FR 5686 to Edinburgh leaves the gate
23 h 50 apart on the timetable, overnight
FR 5686 leaves 23 h 50 after FR 3877 arrives on the timetable: more than half a day, so not a connection we count.