FR 5316 then BT 686 at Madrid
Rome → Madrid → Riga
Timetable, Madrid time
23:40FR 5316 from Rome at the gate
17:15BT 686 to Riga leaves the gate
17 h 35 apart on the timetable, overnight
BT 686 leaves 17 h 35 after FR 5316 arrives on the timetable: more than half a day, so not a connection we count.