{"raw_statement":[{"iden":"statement","content":"The master witcher Geralt of Rivia is going to hunt Cuber QQ, who is a notorious monster in Jungle-Brain. Geralt's attack value is denoted by an integer $a_g$, and his defense value is denoted by an integer $d_g$. Similarily, Cuber QQ's attack value and defense values are denoted by two integer $a_c$, $d_c$. Meanwhile, the initial Health Point (HP) of Cuber QQ is an integer $n$, and Geralt has infinite amount of HP, because he can drink potions to recover from damage. \n\nThe damage of an attack will be reduced by the receiver's defense value, i.e., if the attack value is $a$ and the opponent's defense value is $d$, the actual damage caused is $max (0, a -d)$. The combat will go as follows. Geralt and Cuber QQ take turns to attack. Assuming currently Cuber QQ's HP is $h p$. Geralt will attack first, and Cuber QQ will receive a damage of $max (0, a_g -d_c)$. and its HP would be $h p -max (0, a_g -d_c)$. Once Cuber QQ's HP reaches zero or less, he will be dead and Geralt wins the combat, otherwise Cuber QQ will fight back, causing damage $max (0, a_c -d_g)$.\n\nGeralt can pay crowns (some kind of money used in Jungle-Brain, to upgrade his attack value and defense value. He can pay $a$ crowns to increase his attack value by 1, and increase his defense value by $1$ at the cost of $b$ crowns. However, he only has $m$ crowns so the total number of crowns he pays must be no more than $m$. *Note that he can add any rational number of attack and defense*, e.g., he can pay $frac(3 a, 5)$ crowns to increase $frac(3, 5)$ attack.\n\nGeralt wants to minimize the damage he receives. Please tell him the minimal damage he shall receive if he plans optimally to upgrade. If Geralt can't defeat the monster, output $-1$ instead.\n\nThe first line of the input contains one integer $t$ ($1 <= t <= 10^4$), denoting the number of test cases. Then $t$ test cases follow.\n\nEach case contains two lines.\n\nThe first line contains four space-separated integers $a_g$, $d_g$, $a_c$, $d_c$ ($1 <= a_g, d_g, a_c, d_c <= 10^4$), denoting the attack value and the defense value of Geralt and Cuber QQ respectively.\n\nThe second line contains another four space-separated integers $n$, $m$, $a$, $b$ ($1 <= n, m, a, b <= 10^4$) denoting Cuber QQ's initial HP, the amount of crowns Geralt has, the unit cost of attack upgrade and the unit cost of defense upgrade.\n\nFor each case, output the answer in the form of a completely reduced fraction \"$x \\/ y$\", where $x$ and $y$ are relatively prime integers in a line denoting the minimal amount of damage Geralt will receive from Cuber QQ or $-1$ if Geralt cannot win at all.\n\n"},{"iden":"input","content":"The first line of the input contains one integer $t$ ($1 <= t <= 10^4$), denoting the number of test cases. Then $t$ test cases follow.Each case contains two lines.The first line contains four space-separated integers $a_g$, $d_g$, $a_c$, $d_c$ ($1 <= a_g, d_g, a_c, d_c <= 10^4$), denoting the attack value and the defense value of Geralt and Cuber QQ respectively.The second line contains another four space-separated integers $n$, $m$, $a$, $b$ ($1 <= n, m, a, b <= 10^4$) denoting Cuber QQ's initial HP, the amount of crowns Geralt has, the unit cost of attack upgrade and the unit cost of defense upgrade."},{"iden":"output","content":"For each case, output the answer in the form of a completely reduced fraction \"$x \\/ y$\", where $x$ and $y$ are relatively prime integers in a line denoting the minimal amount of damage Geralt will receive from Cuber QQ or $-1$ if Geralt cannot win at all."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ t \\in \\mathbb{Z}^+ $ be the number of test cases.  \nFor each test case:  \n- Let $ a_g, d_g \\in \\mathbb{Z}^+ $ denote Geralt’s initial attack and defense.  \n- Let $ a_c, d_c \\in \\mathbb{Z}^+ $ denote Cuber QQ’s attack and defense.  \n- Let $ n \\in \\mathbb{Z}^+ $ denote Cuber QQ’s initial HP.  \n- Let $ m, a, b \\in \\mathbb{Z}^+ $ denote Geralt’s available crowns, cost per unit attack upgrade, and cost per unit defense upgrade.  \n\nLet $ x \\in \\mathbb{R}_{\\geq 0} $, $ y \\in \\mathbb{R}_{\\geq 0} $ denote the amount of attack and defense upgrades respectively.  \n\n**Constraints**  \n1. $ a x + b y \\leq m $  \n2. $ a_g + x > d_c $ (necessary to deal positive damage)  \n3. $ n \\leq \\sum_{k=1}^{\\infty} \\max(0, a_g + x - d_c) $ over Geralt’s turns (i.e., Geralt must kill Cuber QQ)  \n\n**Objective**  \nMinimize the total damage Geralt receives:  \n$$\nD = \\left\\lfloor \\frac{n - 1}{\\max(0, a_g + x - d_c)} \\right\\rfloor \\cdot \\max(0, a_c - d_g - y)\n$$  \nsubject to the above constraints.  \n\nIf no $ x, y \\geq 0 $ satisfy $ a_g + x > d_c $ and $ n \\leq \\left\\lceil \\frac{n}{\\max(0, a_g + x - d_c)} \\right\\rceil \\cdot \\max(0, a_g + x - d_c) $ with $ a x + b y \\leq m $, output $-1$.  \n\nOtherwise, output the minimal $ D $ as a reduced fraction $ \\frac{x}{y} $.","simple_statement":"Geralt fights Cuber QQ. Geralt attacks first, then Cuber QQ replies, alternating.  \n\nEach attack deals: `max(0, attacker_attack - defender_defense)` damage.  \n\nGeralt has:  \n- Attack: `a_g`, Defense: `d_g`  \n- Can spend up to `m` crowns to upgrade:  \n  - `a` crowns per +1 attack  \n  - `b` crowns per +1 defense  \n  - He can spend fractional crowns for fractional upgrades  \n\nCuber QQ has:  \n- Attack: `a_c`, Defense: `d_c`, HP: `n`  \n\nGoal: Minimize total damage Geralt receives from Cuber QQ, **if Geralt can kill Cuber QQ**.  \nIf he can’t kill Cuber QQ, output `-1`.  \n\nOutput the minimal damage as a reduced fraction `x/y`, or `-1`.","has_page_source":false}