On performing the flame test salt P produces a lilac coloured flame. This indicates potassium salt.
Its solution gives a white precipitate with silver nitrate solution, which is soluble in Ammonium hydroxide solution. This indicates presence of chloride ion.
KCl+AgNO3→AgCl↓ white ppt +KNO3
AgCl+2NH4OH→[Ag(NH3)2Cl]+2H2O soluble complex
Hence, the salt P is potassium chloride.