The correct option is D 2, 8, 2
The atomic number of magnesium is 12.
The maximum number of electrons that the K, L, and M shells can accommodate are 2, 8, and 18 respectively.
Filling of electrons in the shells takes place in the order: K, L, M.
Hence, the electronic configuration of magnesium is-
ShellKLMNumber of electrons 2 8 2