Solution (source code)

= Solution

<Stokes theorem> gives
$$
I=\oint_{\partial S}\mathbf A\mathbin\cdot d\mathbf r.
$$
For the upward orientation, the outer circle $r=2,z=1$ is counterclockwise from above and the inner circle $r=1,z=4$ is clockwise. On a counterclockwise circle of radius $R$ and height $z$,
$$
\oint\mathbf A\mathbin\cdot d\mathbf r
=-R^2\int_0^{2\pi}(3\sin^2\theta+z\cos^2\theta)\,d\theta
=-\pi R^2(3+z).
$$
The outer circle contributes $-16\pi$. The inner circle would contribute $-7\pi$ counterclockwise and hence contributes $+7\pi$ with its induced clockwise orientation. Thus
$$
\boxed{I=-16\pi+7\pi=-9\pi},
$$
agreeing with the direct calculation.