How $a^{\log_b x} = x^{\log_b a}$?
For any positive $r$ and any $s$, you have $$r^s = b^{\log_b(r^s)} = b^{s\log_b(r)}.$$ So, taking $r=a$ and $s=\log_b(x)$, we have: \begin{align*} a^{\log_b(x)} &= b^{\log_b(x)\log_b(a)}\\ &= b^{\log_b(a)\log_b(x)}\\ & = b^{\log_b(x^{\log_b(a)})}\\ &= x^{\log_b(a)}. \end{align*}
HINT $\rm\ \ \ log(A^{\log X})\ =\ log\ X\ \ log\ A\ =\ log(X^{\log A})\:,\ $ where $\rm\ log := log_b$