FR 3877 then FR 3831 at Madrid
Tangier → Madrid → Bologna
Timetable, Madrid time
22:35FR 3877 from Tangier at the gate
21:00FR 3831 to Bologna leaves the gate
22 h 25 apart on the timetable, overnight
FR 3831 leaves 22 h 25 after FR 3877 arrives on the timetable: more than half a day, so not a connection we count.