(N/A) When an alkaline earth metal is heated,the valence electrons get excited to a higher energy level.
When this excited electron returns to its ground state,it releases energy in the form of light.
If this energy corresponds to the visible region of the electromagnetic spectrum,a characteristic colour is observed.
In $Be$ and $Mg$,the valence electrons are very strongly bound to the nucleus due to their small size and high ionization enthalpy.
The energy required to excite these electrons to a higher energy level is very high,and the energy released upon their return to the ground state does not fall within the visible region of the spectrum.
Therefore,$Be$ and $Mg$ do not impart any characteristic colour to the flame.