CF1633C.Kill the Monster

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Kill the Monster

Monocarp is playing a computer game. In this game, his character fights different monsters.

A fight between a character and a monster goes as follows. Suppose the character initially has health hCh_C and attack dCd_C; the monster initially has health hMh_M and attack dMd_M. The fight consists of several steps:

  1. the character attacks the monster, decreasing the monster's health by dCd_C;
  2. the monster attacks the character, decreasing the character's health by dMd_M;
  3. the character attacks the monster, decreasing the monster's health by dCd_C;
  4. the monster attacks the character, decreasing the character's health by dMd_M;
  5. and so on, until the end of the fight.

The fight ends when someone's health becomes non-positive (i. e. 00 or less). If the monster's health becomes non-positive, the character wins, otherwise the monster wins.

Monocarp's character currently has health equal to hCh_C and attack equal to dCd_C. He wants to slay a monster with health equal to hMh_M and attack equal to dMd_M. Before the fight, Monocarp can spend up to kk coins to upgrade his character's weapon and/or armor; each upgrade costs exactly one coin, each weapon upgrade increases the character's attack by ww, and each armor upgrade increases the character's health by aa.

Can Monocarp's character slay the monster if Monocarp spends coins on upgrades optimally?

Input

The first line contains one integer tt (1t51041 \le t \le 5 \cdot 10^4) — the number of test cases. Each test case consists of three lines:

The first line contains two integers hCh_C and dCd_C (1hC10151 \le h_C \le 10^{15}; 1dC1091 \le d_C \le 10^9) — the character's health and attack;

The second line contains two integers hMh_M and dMd_M (1hM10151 \le h_M \le 10^{15}; 1dM1091 \le d_M \le 10^9) — the monster's health and attack;

The third line contains three integers kk, ww and aa (0k21050 \le k \le 2 \cdot 10^5; 0w1040 \le w \le 10^4; 0a10100 \le a \le 10^{10}) — the maximum number of coins that Monocarp can spend, the amount added to the character's attack with each weapon upgrade, and the amount added to the character's health with each armor upgrade, respectively.

The sum of kk over all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, print YES if it is possible to slay the monster by optimally choosing the upgrades. Otherwise, print NO.

Note

In the first example, Monocarp can spend one coin to upgrade weapon (damage will be equal to 55), then health during battle will change as follows: $(h_C, h_M) = (25, 9) \rightarrow (25, 4) \rightarrow (5, 4) \rightarrow (5, -1)$. The battle ended with Monocarp's victory.

In the second example, Monocarp has no way to defeat the monster.

In the third example, Monocarp has no coins, so he can't buy upgrades. However, the initial characteristics are enough for Monocarp to win.

In the fourth example, Monocarp has 44 coins. To defeat the monster, he has to spend 22 coins to upgrade weapon and 22 coins to upgrade armor.

Samples

4
25 4
9 20
1 1 10
25 4
12 20
1 1 10
100 1
45 2
0 4 10
9 2
69 2
4 2 7
YES
NO
YES
YES

在线编程 IDE

建议全屏模式获得最佳体验