FR 5357 then FR 5484 at Madrid
Krakow → Madrid → Porto
Timetable, Madrid time
22:20FR 5357 from Krakow at the gate
21:40FR 5484 to Porto leaves the gate
23 h 20 apart on the timetable, overnight
FR 5484 leaves 23 h 20 after FR 5357 arrives on the timetable: more than half a day, so not a connection we count.