Let the distances for the two parts of the journey be F and S, and S=F-38.5.
Let T1 be the time for the first part of the journey and T2 the time for the second part.
F=22T1, S=33T2=F-38.5; F+S=25(T1+T2); 2F-38.5=25(F/22+(F-38.5)/33).
Multiply the last equation by 66: 132F-2541=75F+50F-1925.
(132-75-50)F=2541-1925; 7F=616 and F=88km, so S=F-38.5=49.5km.
Length of 1st part of journey=88km and 2nd part of journey=49.5km.
CHECK
T1=88/22=4hr; T2=49.5/33=1.5hr. T1+T2=5.5hr; total distance=137.5km.
Average speed=137.5/5.5=25km/hr. So average speed checks out.