Theoretical study of the anions of BeF2 and MgF2