{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e\n Calculating and comparing time complexity for algorithms are the most important necessary skills for CS students.\u003cbr\u003e\u003cbr\u003e\n 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. \u003cbr\u003e\u003cbr\u003e\n Let $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\n \\begin{align*}\u003cbr\u003e\n g_A(n) \u003d \\begin{cases}\u003cbr\u003e\n f_{A_1}(n) \u0026amp; |A| \u003d 1 \\\\\u003cbr\u003e\n f_{A_1}(n)^{g_B(n)} \u0026amp; |A| \u0026gt; 1\u003cbr\u003e\n \\end{cases}\u003cbr\u003e\n \\end{align*}\u003cbr\u003e\u003cbr\u003e\n For 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\u003e\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 \u003d 0$, output $-1$; if $k \u003d +\\infty $, output $1$; otherwise output $0$.\n\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\u003e\nFor 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\u003e\nThe 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\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/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e1\r\n-1\r\n-1\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}