First of all, Z is unknown. I hope it is a mistake.
Now, it is given that the element X has nineteen electrons. This proves that X is actually Potassium.
As per the periodic table, both Potassium and Lithium belongs to group 1 as their valency is 1 because of the presence of only one electron in the outermost shell of electrons i.e., they lose an electron during a chemical reaction to form a stable compound. Furthermore, both are metallic.
Magnesium belongs to group 2 and hence its valency is two, which is different from potassium though it is metallic. Similiarly, bromine belongs to group 17 and gains one electron during a reaction in contrast to potassium.
( No internal links available for reference. For clarification, check the periodic table).