The European Union went back to its roots Monday by picking cities from two of its founding nations — France and the Netherlands — to host key agencies that will have move once Britain leaves the bloc in 2019.

During voting so tight they were both decided by a lucky draw, EU members except Britain chose Amsterdam over Italy’s Milan as the new home of the European Medicines Agency and Paris over Dublin to host the European Banking Authority. Both currently are located in London.

“We needed to draw lots in both cases,” Estonian EU Affairs Minister Matti Maasikas, who chaired the meeting and in both cases made the decisive selection from a big transparent bowl.

Frankfurt, home of the European Central Bank, surprisingly failed to become one of the two finalists competing for the banking agency.

The relocations made necessary by the referendum to take Britain out of the EU are expected to cost the country over 1,000 jobs directly and more in secondary employment.

The outcomes of the votes also left newer EU member states in eastern and southern Europe with some bitterness. Several had hoped to be tapped for a lucrative prize that would be a sign the bloc was truly committed to outreach.

Some 890 top jobs will leave Britain for Amsterdam with the European Medicines Agency, giving the Dutch a welcome economic boost and more prestige. The EMA is responsible for the evaluation, supervision and monitoring of medicines. The Paris-bound European Banking Authority, which has around 180 staff members, monitors the regulation and supervision of Europe’s banking sector.

After a heated battle for the medicines agency, Amsterdam and Milan both had 13 votes Monday. That left Estonia, which currently holds the rotating EU presidency, to break the tie with a draw from the bowl. Copenhagen finished third, ahead of Slovakian capital Bratislava in the vote involving EU nations excluding Britain. One country abstained in the vote.

“A solid bid that was defeated only by a draw. What a mockery,” Italian Prime Minister Paolo Gentiloni said on Twitter.

Dutch Foreign Minister Halbe Zijlstra was elated.

“It is a fantastic result,” he said. “It shows that we can deal with the impact of Brexit”

The European Medicines Agency has less than 17 months to complete the move, but Amsterdam was considered ideally suited because of its location, the building it had on offer and other facilities.

Even though rules were set up to make it a fair decision, the process turned into a deeply political contest.

Zijlstra said that “in the end, it is a very strategic game of chess.”