{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eCalculating and comparing time complexity for algorithms are the most important necessary skills for CS students.\u003cbr\u003e\u003cbr\u003eThis 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. \u003cbr\u003e\u003cbr\u003eLet $f_a(n) \u003d \\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$):\u003cbr\u003e\\begin{align*}\u003cbr\u003eg_A(n) \u003d \\begin{cases}\u003cbr\u003ef_{A_1}(n) \u0026amp; |A| \u003d 1 \\\\\u003cbr\u003ef_{A_1}(n)^{g_B(n)} \u0026amp; |A| \u0026gt; 1\u003cbr\u003e\\end{cases}\u003cbr\u003e\\end{align*}\u003cbr\u003e\u003cbr\u003eFor example, $g_{[1,2]}(n) \u003d (\\log n) ^{\\log \\log n}$ and $g_{[3,1,1]}(n) \u003d (\\log \\log \\log n) ^{(\\log n) ^{\\log n}}$.\u003cbr\u003e\u003cbr\u003eNow, 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 \u003d 0$, output $-1$; if $k \u003d +\\infty $, output $1$; otherwise output $0$.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a single number $t(1 \\leq t \\leq 10^5)$, the number of testcases.\u003cbr\u003e\u003cbr\u003eFor each testcase, the first line contains two integers $a,b(1 \\leq a,b \\leq 3)$, the length of $A$ and $B$.\u003cbr\u003e\u003cbr\u003eThe second line contains $a$ integers $A_i$ and the third line contains $b$ integers $B_i(1 \\leq A_i,B_i \\leq 10^9)$, which describe $A$ and $B$."}},{"title":"Output","value":{"format":"HTML","content":"For each testcase, output a single line with a single integer, the answer."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n1 1\r\n1\r\n2\r\n2 2\r\n1 2\r\n2 1\r\n1 3\r\n1\r\n1000000000 3 3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n-1\r\n-1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}