Split the problem in two parts, 25 years and 18 years.
The interest rate is known for the first part (7% p.a. or per month?) and compounded monthly. So the future value after 25 years is determined, say A.
Assuming A<400,000=target, subtract
remaining future value B=400,000-A and calculate deposit required for 18 remaining years at the given interest rate.
For the second part, the future value after (a further) 18 years is known,