The correct option is D Oxygen and magnesium
Oxygen (Z=8) has 4 s electrons and 4 p electrons
Mg (Z=12) has 6 s and 6 p electrons
Nitrogen (Z=7) has 4 s and 3 p electrons.
Fluorine (Z=9) has 4 s and 5 p electrons.
Helium (Z=2) has 2 s and 0 p electrons.
Beryllium (Z= 4) 4 s and 0 p electrons.
Thus, oxygen and magnesium have as many s electrons as p electrons.