Effect of zeroes in system stability

Suppose we have two third order systems (a and b), with three poles and two zeroes,poles for both the systems are at the same positions in frequency domain but these systems differ in the placement of their zeroes as shown in the figure below:

The abovve figure is a plot of the loop gain of the systems. Here za1 and za2 are the zeroes for system a and zb1 and zb2 for system b. The exact shape of the magnitude plot of loop gain would differ for the two plots, I only intend to highlight the position of zeroes for the two systems.
In system a the zeroes lie before the unity loop gain frequency whereas in system b they lie after the unity loop gain frequency. Suppose unity gain frequency lies away from the zeroes of both the systems. Clearly the phase margin in case a is close to 90deg while that in case b is close to 270deg. Thus we would conclude that system b is unstable.
My question is, since the stability depends only on the system poles which are same in both the cases, how do these systems differ in their stability?

The stability depends on both the poles and the zeros of the plant and controller.

To see this consider the asymptotes of the diagram of the loop gain/phase. Imagine moving the zeros changes the phase at crossover and therefore affects the stability.

Looking at it more formally, the dynamic characteristics and stability are determined by the poles of the closed loop transfer function.

Consider a control system as shown below.

Let the plant be represented as a transfer function of poles and zeros $$G=B/A$$ and let the Feedback (or controller) be represented as a transfer function of poles and zeros $$H=S/R$$

The closed loop transfer function is therefore: $$\dfrac{B/A}{1+\dfrac{BS}{AR}}$$ Where the demoniator is the characteristic equation which determines stability. Simplifying: $$\dfrac{BR}{AR+BS}$$

So the stability is determined by the characteristic equation (poles): $$AR+BS=0$$

Therefore the stability depends on the poles and the zeros.