All the given metal sulfides (NiS, ZnS, CdS, HgS) are of the type MS, where M is a divalent metal ion (M$^{2+}$) and S is sulfide ion (S$^{2-}$).
The precipitation reaction is M$^{2+}$(aq) + S$^{2-}$(aq) $\rightleftharpoons$ MS(s).
The solubility product constant is $K_{sp} = [\text{M}^{2+}][\text{S}^{2-}]$.
When H$_2$S gas is passed into the solution, it provides S$^{2-}$ ions. As the concentration of S$^{2-}$ ions gradually increases (due to H$_2$S being passed very slowly), precipitation of a metal sulfide MS will begin when its ionic product $[\text{M}^{2+}][\text{S}^{2-}]$ exceeds its $K_{sp}$.
Given that all metal ions (Ni$^{2+}$, Zn$^{2+}$, Cd$^{2+}$, Hg$^{2+}$) have equal initial concentrations, let this concentration be $C$.
So, $[\text{M}^{2+}] = C$ for all of them initially.
Precipitation starts when $[\text{S}^{2-}]>\frac{K_{sp}}{[\text{M}^{2+}]} = \frac{K_{sp}}{C}$.
The metal sulfide with the smallest $K_{sp}$ will require the lowest concentration of S$^{2-}$ ions to start precipitating. Therefore, it will be the first to precipitate.
The metal sulfide with the largest $K_{sp}$ will require the highest concentration of S$^{2-}$ ions to start precipitating. Therefore, it will be the last to precipitate (among those that do precipitate).
Given $K_{sp}$ values:
$K_{sp}(\text{NiS}) = 4.7 \times 10^{-1}$ (Note: Image says $4.7 \times 10^{-1}$, but this value is extremely high for a sulfide, usually they are very insoluble. For NiS, typical $K_{sp}$ is around $10^{-19}$ to $10^{-21}$. This value of $4.7 \times 10^{-1}$ might be a typo and could mean $4.7 \times 10^{-19}$ or similar. Let's proceed with the given value and see.)
$K_{sp}(\text{ZnS}) = 1.6 \times 10^{-24}$
$K_{sp}(\text{CdS}) = 8 \times 10^{-27}$
$K_{sp}(\text{HgS}) = 4 \times 10^{-53}$
Let's compare these $K_{sp}$ values:
Smallest $K_{sp}$: $K_{sp}(\text{HgS}) = 4 \times 10^{-53}$.
Largest $K_{sp}$: $K_{sp}(\text{NiS}) = 4.7 \times 10^{-1}$.
The order of $K_{sp}$ values from smallest to largest is:
HgS ($4 \times 10^{-53}$)<CdS ($8 \times 10^{-27}$)<ZnS ($1.6 \times 10^{-24}$)<NiS ($4.7 \times 10^{-1}$).
The first ion to precipitate will be from the sulfide with the smallest $K_{sp}$: HgS.
So, Hg$^{2+}$ is the first ion to precipitate.
The last ion to precipitate will be from the sulfide with the largest $K_{sp}$: NiS.
So, Ni$^{2+}$ is the last ion to precipitate.
Therefore, the first ion to precipitate is Hg$^{2+}$ and the last is Ni$^{2+}$.
This matches option (d).
The unusually high $K_{sp}$ for NiS ($0.47$) means it's relatively soluble compared to other typical sulfides. However, the principle remains: smallest $K_{sp}$ precipitates first, largest $K_{sp}$ precipitates last. If $4.7 \times 10^{-1}$ is taken as is, NiS is by far the most soluble and would precipitate last.
It is important to use the values *as given* in the problem, even if they seem unusual compared to literature values.
Order of precipitation: Hg$^{2+}$ (first), then Cd$^{2+}$, then Zn$^{2+}$, then Ni$^{2+}$ (last).
\[ \boxed{\text{Hg}^{2+}\text{, Ni}^{2+}} \]