When you add HCl to the mixture, pyridine forms pyridinium hydrochloride, which is water soluble. p-toluenebenzoic acid and naphthalene don't dissolve in HCl.
p-toluenebenzoic acid can be dissolved in a base like NaOH probably, with the formation of the sodium salt. And pyridine and naphthalene dont react with NaOH.