The rot in Nigeria’s educational system is costing the country hundreds of millions of dollars.

Over the past academic year, the economic impact of spending by Nigerian students studying in the United States reached $514 million, data from the Institute of International Education shows. The figure outstrips the economic impact of students from France, Germany and the United Kingdom in the US.

Keeping in trend with a long-standing preference for seeking education abroad, Nigeria was the only African country ranked among the top 25 origin countries for international students in the US over the past year.

The entire budgetary allocation for education in Nigeria for 2019 came in at $1.7 billion (620.5 billion naira), which critics pointed out was 15% to 20% below the minimum level recommended for developing countries by the United Nations Educational Scientific and Cultural Organisation (UNESCO).

Nigerian students studying in the US crossed the 13,000 mark in the last academic year—double the number at the start of the decade. In comparison, there have never been more than 50 US students studying in Nigeria each year in the last decade.

The choice of seeking education in the US is largely driven by local problems. Perennial under-funding of education in Nigeria has resulted in significant decline in both the quality of teachers and infrastructure in schools. At the tertiary level, the problems are compounded by recurring strike actions by public university lecturers amid protests of low wages and benefits.

These problems have fueled a rise in expensive private universities which offer the promise of fixed calendars without strike action and better facilities as viable alternatives for middle and high-income families seeking higher standards. But there’s still a capacity problem as Nigeria’s university system, which holds over 150 schools, remains mostly over-populated. As such, only one in four Nigerians applying to university will get a spot. Between 2010 and 2015, only 26% of the 10 million applicants that sought entry into Nigerian tertiary institutions gained admission, according to Nigeria’s statistics agency.

The appeal of foreign universities also goes beyond the availability of better facilities as parents typically seek to unlock a higher level of opportunities for their children. It’s a sentiment that’s currently driving migration of middle-class Nigerians to Canada and Europe.

In cases where the students return home, their expensive, foreign degrees also provide an edge in Nigeria’s very competitive labor market. In comparison, about half of graduates from Nigerian universities annually are estimated to remain unemployed.

Sign up to the Quartz Africa Weekly Brief here for news and analysis on African business, tech and innovation in your inbox