So here not only there are impulses between the spheres, but also between each sphere and the ground. The result is a system of equations with three expressions and three unknown impulses.
For the contact acting on the i-th body from the j-th body (or ground), consider the contact normal $\hat{n}_{ij}$, the impulse $J_{ij}$ and the contact conditions
$$ \hat{n}_{ij} \cdot ( \vec{v}_i^\star - \vec{v}_j^\star ) = -\epsilon_{ij}\, \hat{n}_{ij} \cdot ( \vec{v}_i - \vec{v}_j ) \tag{1}$$
where $\vec{v}_i$ is the velocity vector of the i-th body before impact and $\vec{v}_i^\star$ after impact. The same for $\vec{v}_j$. Finally, $\epsilon_{ij}$ is the coefficient of restitution for the contact.

For the contact normal vectors above, I suppose the contacts with the ground have zero COR and the contact between the spheres has 1.
The result of all impacts to each body is
$$ \begin{aligned}
\vec{v}_1^\star &= \vec{v}_1 + \frac{1}{m_1} \left( \hat{n}_{12} J_{12} + \hat{n}_{10} J_{10} \right) \\
\vec{v}_2^\star &= \vec{v}_2 + \frac{1}{m_2} \left( -\hat{n}_{12} J_{12} + \hat{n}_{20} J_{20} \right)\\
\end{aligned} \tag{2}$$
These two expressions are used in the following 3 contacts to make the system in terms of the three terms $J_{ij}$ only
$$\begin{aligned}
\hat{n}_{12} \cdot ( \vec{v}_1^\star - \vec{v}_2^\star ) & = -\epsilon_{12}\, \hat{n}_{12} \cdot ( \vec{v}_1 - \vec{v}_2 ) \\
\hat{n}_{10} \cdot ( \vec{v}_1^\star ) & = -\epsilon_{10}\, \hat{n}_{10} \cdot ( \vec{v}_1 ) \\
\hat{n}_{20} \cdot ( \vec{v}_2^\star ) & = -\epsilon_{20}\, \hat{n}_{20} \cdot ( \vec{v}_2 )
\end{aligned}$$