Let \( f: (0, \pi) \to \mathbb{R} \) be a function given by
\[ f(x) = \begin{cases} \left(\frac{8}{7}\right)^{\tan 8x / \tan 7x}, & 0 < x < \frac{\pi}{2} \\ a - 8, & x = \frac{\pi}{2} \\ \left(1 + |\cot x|\right)^{b^{\lfloor \tan x \rfloor}}, & \frac{\pi}{2} < x < \pi \end{cases} \]
Where \( a, b \in \mathbb{Z} \). If \( f \) is continuous at \( x = \frac{\pi}{2} \), then \( a^2 + b^2 \) is equal to __________.