Calculating and comparing time complexity for algorithms are the most important necessary skills for CS students.
This semester, Rikka applies for the assistant of course "Algorithm Analysis". Now Rikka needs to set problems for the final examination, and she is going to set some tasks about time complexity.
Let $f_a(n) = \log \dots \log n$ (there are exactly $a$ $\log$ in this function, and $\log$ uses base $2$). And then, for an integer array $A$, Rikka defines $g_A(n)$ in the following way ($B$ is the suffix of $A$ with length $|A| - 1$):
\begin{align*}
g_A(n) = \begin{cases}
f_{A_1}(n) & |A| = 1 \\
f_{A_1}(n)^{g_B(n)} & |A| > 1
\end{cases}
\end{align*}
For example, $g_{[1,2]}(n) = (\log n) ^{\log \log n}$ and $g_{[3,1,1]}(n) = (\log \log \log n) ^{(\log n) ^{\log n}}$.
Now, given integer arrays $A$ and $B$, Rikka wants you to compare $g_A(n)$ with $g_B(n)$. i.e., let $k$ be $\lim_{n \rightarrow +\infty}\frac{g_A(n)}{g_B(n)}$. If $k = 0$, output $-1$; if $k = +\infty $, output $1$; otherwise output $0$.