The mercury atom is excited one of its electrons goes from an upper electron shell to a lower electron shell thanks to some energy that it recives from the outside. When an atom is excited it is instable so the electron will go back to its initial shell. This will cause a loss of enregy in the form of a photon