P10640 BZOJ2356 Inequality

Description

There are many inequalities in mathematics. For example, when $x,y>0$: $$x^2+y^2 \geq 2xy$$ $$x^3+y^3 \geq x^2y+xy^2$$ You are given two homogeneous bivariate polynomials $f(x,y)$ and $g(x,y)$, both with non-negative coefficients. Determine whether there exist $A,r>0$ such that for any $x,y>0$, the following always holds: $f(x,y)\geq Ag(x,y)^r$.

Input Format

The input contains multiple test cases. Adjacent test cases are separated by one blank line. Each test case contains two lines. The first line contains $n+2$ non-negative integers $n,a_0,a_1,\dots,a_n$, where the $a_i$ are not all $0$, representing $f(x,y)=a_0x^n+a_1x^{n-1}y+\dots+a_ny^n$. The second line contains $m+2$ non-negative integers $m,b_0,b_1,\dots,b_m$, where the $b_i$ are not all $0$, representing $g(x,y)=b_0x^m+b_1x^{m-1}y+\dots+b_my^m$.

Output Format

For each test case, output one line. If such $A,r$ exist, output `YES`; otherwise, output `NO`.

Explanation/Hint

**Sample Explanation** - For the first sample, $x+y \geq \sqrt{2xy}$. - For the second sample, $x^2+xy+y^2\geq \sqrt[3]{(x^3+y^3)^2}$. This is easy to verify after expansion. - For the third sample, assume the opposite: $x^5+x^2y^3 \geq A(x^3y^2+y^5)^r$ holds for all positive $x,y$. Let $x=y$, then $2x^5\geq A(2x^5)^r$. If $r>1$, the inequality fails when $x$ is large enough; if $r