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 $h_C$ and attack $d_C$; the monster initially has health $h_M$ and attack $d_M$. The fight consists of several steps:

the character attacks the monster, decreasing the monster's health by $d_C$;

the monster attacks the character, decreasing the character's health by $d_M$;

the character attacks the monster, decreasing the monster's health by $d_C$;

the monster attacks the character, decreasing the character's health by $d_M$;

and so on, until the end of the fight.

The fight ends when someone's health becomes non-positive (i. e. $0$ 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 $h_C$ and attack equal to $d_C$. He wants to slay a monster with health equal to $h_M$ and attack equal to $d_M$. Before the fight, Monocarp can spend up to $k$ 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 $w$, and each armor upgrade increases the character's health by $a$.

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


-----Input-----

The first line contains one integer $t$ ($1 \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 $h_C$ and $d_C$ ($1 \le h_C \le 10^{15}$; $1 \le d_C \le 10^9$) — the character's health and attack;

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

The third line contains three integers $k$, $w$ and $a$ ($0 \le k \le 2 \cdot 10^5$; $0 \le w \le 10^4$; $0 \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 $k$ over all test cases does not exceed $2 \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.


-----Examples-----

Input
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
Output
YES
NO
YES
YES


-----Note-----

In the first example, Monocarp can spend one coin to upgrade weapon (damage will be equal to $5$), 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 $4$ coins. To defeat the monster, he has to spend $2$ coins to upgrade weapon and $2$ coins to upgrade armor.

Difficulty: EASY
Tags: Mathematics

Complete search
Skill types: Complete search

Starter code:

Solutions:
import sys
input = sys.stdin.readline

def solve():
	for n in range(0, k + 1):
		m = k - n
		up_hc = hc + n * a
		up_dc = dc + m * w
		t = up_hc // dm
		if up_hc % dm == 0 and t > 0:
			t -= 1
		if hm - up_dc * (t + 1) <= 0:
			print('YES')
			return
	print('NO')
for _ in range(int(input().strip())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	solve()


import sys, collections

def solve(hc, dc, hm, dm, coins, hp, dp):
	for hcoin in range(coins + 1):
		dcoin = coins - hcoin
		newhc = hc + hcoin * hp
		newdc = dc + dcoin * dp
		mr = hm // newdc + 1 if hm % newdc else hm // newdc
		cr = newhc // dm + 1 if newhc % dm else newhc // dm
		if mr <= cr:
			return 'YES'
	return 'NO'
input = sys.stdin.readline
tests = int(input()[:-1])
for test in range(tests):
	(hc, dc) = [int(s) for s in input()[:-1].split()]
	(hm, dm) = [int(s) for s in input()[:-1].split()]
	(coins, dcup, hcup) = [int(s) for s in input()[:-1].split()]
	print(solve(hc, dc, hm, dm, coins, hcup, dcup))


import sys
input = sys.stdin.readline

def solution() -> str:
	for num_h_up in range(k + 1):
		num_d_up = k - num_h_up
		total_dc = dc + num_d_up * w
		total_hc = hc + num_h_up * a
		c_lifetime = total_hc // dm
		if total_hc % dm > 0:
			c_lifetime += 1
		m_lifetime = hm // total_dc
		if hm % total_dc > 0:
			m_lifetime += 1
		if c_lifetime >= m_lifetime:
			return 'YES'
	return 'NO'
t = int(input())
for tc in range(t):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	sol = solution()
	print(sol)


import sys
input = sys.stdin.readline
num_test_cases = int(input())
for test_case_ittr in range(num_test_cases):
	(health, damage) = [int(x) for x in input().split()]
	(monster_health, monster_damage) = [int(x) for x in input().split()]
	(budget, delta_damage, delta_health) = [int(x) for x in input().split()]
	answer = 'NO'
	health += budget * delta_health
	for i in range(budget + 1):
		num_hits_to_kill_monster = monster_health // damage
		if monster_health % damage:
			num_hits_to_kill_monster += 1
		num_hits_to_die = health // monster_damage
		if health % monster_damage:
			num_hits_to_die += 1
		if num_hits_to_kill_monster <= num_hits_to_die:
			answer = 'YES'
			break
		health -= delta_health
		damage += delta_damage
	print(answer)


import sys, math
input = sys.stdin.readline
a = input()
while True:
	try:
		(hc, dc) = map(int, input().split())
		(hm, dm) = map(int, input().split())
		(kmax, w, a) = map(int, input().split())
	except:
		break
	wins = False
	for k in range(kmax + 1):
		if hc + (kmax - k) * a - dm * (math.ceil(hm / (dc + k * w)) - 1) > 0:
			wins = True
			break
	if wins:
		print('YES')
	else:
		print('NO')


from math import ceil
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	f = 0
	for i in range(0, k + 1):
		c = ceil(hm / (dc + w * i))
		d = ceil((hc + a * (k - i)) / dm)
		if c <= d:
			f = 1
			break
	if f:
		print('YES')
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().rstrip()

def main():
	for _ in range(int(input())):
		(hc, dc) = [int(item) for item in input().split()]
		(hm, dm) = [int(item) for item in input().split()]
		(k, w, a) = [int(item) for item in input().split()]
		initC = hc // dm
		if hc % dm != 0:
			initC += 1
		initM = hm // dc
		if hm % dc != 0:
			initM += 1
		bisa = False
		if initC > initM:
			print('YES')
			bisa = True
		else:
			for i in range(0, k + 1):
				hc += (k - i) * a
				dc += i * w
				initC = hc // dm
				if hc % dm != 0:
					initC += 1
				initM = hm // dc
				if hm % dc != 0:
					initM += 1
				bisa = False
				if initC >= initM:
					print('YES')
					bisa = True
					break
				hc -= (k - i) * a
				dc -= i * w
			if not bisa:
				print('NO')
main()


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
mod = 10 ** 9 + 7
ANS = []
input = stdin.readline

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def solve():
	pass
t = int(input())
for i in range(t):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	f = 0
	for i in range(k + 1):
		aa = i
		ww = k - i
		newHC = hc + a * aa
		newDC = dc + w * ww
		if ceil(hm / newDC) <= ceil(newHC / dm):
			f = 1
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
r = [0] * t
for j in range(t):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	for i in range(k + 1):
		nhc = hc + i * a
		ndc = dc + (k - i) * w
		if (hm + ndc - 1) // ndc <= (nhc + dm - 1) // dm:
			r[j] = 'YES'
			break
	else:
		r[j] = 'NO'
print('\n'.join(r))


import sys
input = sys.stdin.readline
import math
for _ in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	x = k
	while x >= 0:
		if math.ceil((a * x + hc) / dm) >= math.ceil(hm / (dc + w * (k - x))):
			print('YES')
			break
		x -= 1
	if x < 0:
		print('NO')


import math
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(hc, dc) = [int(i) for i in input().split()]
	(hm, dm) = [int(i) for i in input().split()]
	(k, w, a) = [int(i) for i in input().split()]
	flag = 0
	for i in range(k + 1):
		b = i
		v = k - i
		newH = hc + a * b
		newD = dc + w * v
		if math.ceil(hm / newD) <= math.ceil(newH / dm):
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


import sys
for _ in range(int(sys.stdin.readline())):
	(p, q) = map(int, sys.stdin.readline().split())
	(x, y) = map(int, sys.stdin.readline().split())
	(k, w, a) = map(int, sys.stdin.readline().split())
	for i in range(0, k + 1):
		if (p + i * a) % y == 0:
			n1 = (p + i * a) / y
		else:
			n1 = (p + i * a) // y + 1
		if x % (q + (k - i) * w) == 0:
			n2 = x / (q + (k - i) * w)
		else:
			n2 = x // (q + (k - i) * w) + 1
		if n1 >= n2:
			print('YES')
			break
	else:
		print('NO')


import sys
input = sys.stdin.readline
from math import ceil

def check(a, b, c, d):
	p = ceil(c / b)
	q = ceil(a / d)
	if p <= q:
		return True
	return False
t = int(input())
for _ in range(t):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	flag = True
	for i in range(k + 1):
		if check(hc + i * a, dc + (k - i) * w, hm, dm):
			print('YES')
			flag = False
			break
	if flag:
		print('NO')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(x, y) = map(int, input().split())
	(n, j, k) = map(int, input().split())
	f = 0
	for i in range(n + 1):
		l = (a + i * k) // y
		if (a + i * k) % y:
			l += 1
		l1 = x // (b + j * (n - i))
		if x % (b + j * (n - i)):
			l1 += 1
		if l >= l1:
			f = 1
			break
	if f:
		print('YES')
	else:
		print('NO')


import sys
import math

def willWin(h, d, h_m, d_m):
	myHits = math.ceil(h_m / d)
	monsterHits = math.ceil(h / d_m)
	if myHits > monsterHits:
		return False
	return True

def upgrade(coin, weapon, armor, h, d, h_m, d_m):
	for i in range(coin + 1):
		health = i * armor + h
		attack = (coin - i) * weapon + d
		if willWin(health, attack, h_m, d_m):
			return 'YES'
	return 'NO'
first = True
count = 0
for line in sys.stdin:
	if first:
		first = False
		count += 1
		continue
	arr = line.split()
	if count % 3 == 1:
		h = int(arr[0])
		d = int(arr[1])
	if count % 3 == 2:
		h_m = int(arr[0])
		d_m = int(arr[1])
	if count % 3 == 0:
		coin = int(arr[0])
		weapon = int(arr[1])
		armor = int(arr[2])
		if willWin(h, d, h_m, d_m):
			print('YES')
		else:
			print(upgrade(coin, weapon, armor, h, d, h_m, d_m))
	count += 1


from math import ceil

def Solve():
	T = []
	for t in range(int(input())):
		(hc, dc) = map(int, input().split())
		(hm, dm) = map(int, input().split())
		(k, w, a) = map(int, input().split())
		T.append([hc, dc, hm, dm, k, w, a])
	for (hc, dc, hm, dm, k, w, a) in T:
		for i in range(0, k + 1):
			if ceil((hc + (k - i) * a) / dm) * (i * w + dc) >= hm:
				print('YES')
				break
		else:
			print('NO')
Solve()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	f = 0
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	for i in range(k + 1):
		h = hc + a * i
		d = dc + w * (k - i)
		c1 = (h + dm - 1) // dm
		c2 = (hm + d - 1) // d
		if c1 >= c2:
			f = 1
	print('YES' if f == 1 else 'NO')


import sys
import math
from bisect import bisect_right as br
from collections import deque
from itertools import combinations as cb

def int_arr():
	return list(map(int, sys.stdin.readline().strip().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(ch, cd) = int_arr()
	(mh, md) = int_arr()
	(k, w, a) = int_arr()
	for i in range(k + 1):
		atack = cd + w * i
		x = k - i
		hel = ch + a * x
		if mh // atack + min(1, mh % atack) <= hel // md + min(1, hel % md):
			print('YES')
			break
	else:
		print('NO')


import math
ans = ''
for _ in range(int(input())):
	(hc, dc) = list(map(int, input().split()))
	(hm, dm) = list(map(int, input().split()))
	(k, w, a) = list(map(int, input().split()))
	for i in range(k + 1):
		if math.ceil((hc + i * a) / dm) >= math.ceil(hm / (dc + w * (k - i))):
			ans += 'YES\n'
			break
	else:
		ans += 'NO\n'
print(ans)


import math
n = int(input())
results = [0 for i in range(n)]
for i in range(n):
	(hc, dc) = input().split()
	(hc, dc) = (int(hc), int(dc))
	(hm, dm) = input().split()
	(hm, dm) = (int(hm), int(dm))
	(k, w, a) = input().split()
	(k, w, a) = (int(k), int(w), int(a))
	for j in range(0, k + 1):
		dc_ = dc + w * j
		hc_ = hc + a * (k - j)
		t1 = math.ceil(hc_ / dm)
		t2 = math.ceil(hm / dc_)
		if t2 <= t1:
			results[i] = 1
			break
for e in results:
	print('YES' if e else 'NO')


from math import ceil
results = []
for _ in range(int(input())):
	(healt, damage) = [int(x) for x in input().split()]
	(monster, mondmg) = [int(x) for x in input().split()]
	(money, weapon, armor) = [int(x) for x in input().split()]
	if ceil(monster / damage) <= ceil(healt / mondmg):
		results.append('YES')
	else:
		found = False
		for for_ammo in range(money + 1):
			for_armor = money - for_ammo
			v_health = healt + for_armor * armor
			v_damage = damage + for_ammo * weapon
			if ceil(monster / v_damage) <= ceil(v_health / mondmg):
				results.append('YES')
				found = True
				break
		if not found:
			results.append('NO')
print(*results, sep='\n')


from sys import stdin, maxsize
from collections import defaultdict, Counter
from math import ceil

def rei():
	return list(map(int, stdin.readline().strip().split(' ')))

def res():
	return stdin.readline().rstrip()

def prno():
	print('NO')

def pryes():
	print('YES')

def find(hc, dc, hm, dm):
	tc = ceil(hm / dc)
	tm = ceil(hc / dm)
	if tc <= tm:
		return True
	return False

def solve():
	(hc, dc) = rei()
	(hm, dm) = rei()
	(k, w, a) = rei()
	hcdc = []
	for i in range(k + 1):
		(hhc, ddc) = (hc + i * a, dc + (k - i) * w)
		if find(hhc, ddc, hm, dm):
			pryes()
			return
	prno()
t = rei()[0]
for _ in range(t):
	solve()


import math
t = int(input())
ListA = []
for i in range(t):
	hc = input()
	(hc, ac) = [int(i) for i in hc.split(' ')]
	hm = input()
	(hm, am) = [int(i) for i in hm.split(' ')]
	k = input()
	(k, a, w) = [int(i) for i in k.split(' ')]
	diff = math.ceil(hm / ac) - math.ceil(hc / am)
	if diff > 0:
		count = 0
		for i in range(k + 1):
			attack = ac + i * a
			health = hc + (k - i) * w
			diff = math.ceil(hm / attack) - math.ceil(health / am)
			if diff <= 0:
				count += 1
				break
		if count == 1:
			ListA.append('YES')
		else:
			ListA.append('NO')
	else:
		ListA.append('YES')
for i in ListA:
	print(i)


num_test = int(input())
res = []

def is_char_winner_it(test):
	for coind in range(0, test['coin'] + 1):
		(num_move_m, mod_m) = divmod(test['hc'] + test['hi'] * (test['coin'] - coind), test['dm'])
		(num_move_c, mod_c) = divmod(test['hm'], test['dc'] + test['di'] * coind)
		if mod_c > 0:
			num_move_c += 1
		if mod_m > 0:
			num_move_m += 1
		if num_move_c <= num_move_m:
			return True
	return False
for i in range(0, num_test):
	test = {}
	(test['hc'], test['dc']) = (int(x) for x in input().split())
	(test['hm'], test['dm']) = (int(x) for x in input().split())
	(test['coin'], test['di'], test['hi']) = (int(x) for x in input().split())
	res.append(is_char_winner_it(test))
for el in res:
	print('YES' if el else 'NO')


ans = []
for _ in range(int(input())):
	character = input().split(' ')
	monster = input().split(' ')
	supplements = input().split(' ')
	coins = int(supplements[0])
	for i in range(coins + 1):
		charhealth = int(character[0])
		charattack = int(character[1])
		charhealth += i * int(supplements[2])
		charattack += (coins - i) * int(supplements[1])
		if (charhealth - 1) // int(monster[1]) >= (int(monster[0]) - 1) // charattack:
			ans.append('YES')
			break
	else:
		ans.append('NO')
for i in ans:
	print(i)


import math
T = input()
T = int(T)
health_me = [0] * T
damage_me = [0] * T
health_monster = [0] * T
damage_monster = [0] * T
weapon = [0] * T
armor = [0] * T
coins = [0] * T
for i in range(T):
	(health_me[i], damage_me[i]) = [int(x) for x in input().split()]
	(health_monster[i], damage_monster[i]) = [int(x) for x in input().split()]
	(coins[i], weapon[i], armor[i]) = [int(x) for x in input().split()]

def collect(health_me, damage_me, health_monster, damage_monster, weapon, armor, coins):
	yes = False
	for i in range(coins + 1):
		health_me += armor * i
		damage_me += weapon * (coins - i)
		me_win = health_me / damage_monster
		monster_win = health_monster / damage_me
		me_win = math.ceil(me_win)
		monster_win = math.ceil(monster_win)
		health_me -= armor * i
		damage_me -= weapon * (coins - i)
		if me_win >= monster_win:
			print('YES')
			return
	print('NO')
	return
for i in range(T):
	collect(health_me[i], damage_me[i], health_monster[i], damage_monster[i], weapon[i], armor[i], coins[i])


import sys
from math import ceil
input = sys.stdin.readline
MAX = sys.maxsize
sys.setrecursionlimit(10 ** 9)

def inp():
	return int(input())

def read_int_list():
	return list(map(int, input().split()))

def read_list():
	s = input()
	return list(s[:len(s) - 1])

def read_int_map():
	return map(int, input().split())

def compute_number_hits(dmg, armor):
	return int(ceil(armor / dmg))

def solve(hc, dc, hm, dm, coins, weapon, armor):
	die = compute_number_hits(dm, hc)
	hits = compute_number_hits(dc, hm)
	if hits <= die:
		return 'YES'
	for spent in range(coins):
		new_dc = dc + spent * weapon
		new_hc = hc + (coins - spent) * armor
		die = compute_number_hits(dm, new_hc)
		hits = compute_number_hits(new_dc, hm)
		if hits <= die:
			return 'YES'
		new_dc = dc + (coins - spent) * weapon
		new_hc = hc + spent * armor
		die = compute_number_hits(dm, new_hc)
		hits = compute_number_hits(new_dc, hm)
		if hits <= die:
			return 'YES'
	return 'NO'
for _ in range(inp()):
	(hc, dc) = read_int_list()
	(hm, dm) = read_int_list()
	(k, w, a) = read_int_list()
	print(solve(hc, dc, hm, dm, k, w, a))


def Input():
	(hC, dC, hM, dM, k, a, w) = (0, 0, 0, 0, 0, 0, 0)
	player = input()
	player = player.split(' ')
	monster = input()
	monster = monster.split(' ')
	Data = input()
	Data = Data.split(' ')
	return (int(player[0]), int(player[1]), int(monster[0]), int(monster[1]), int(Data[0]), int(Data[1]), int(Data[2]))

def Solve(hC, dC, hM, dM, k, a, w):
	for curK in range(0, k + 1):
		curMoves = (hC + curK * a) // dM
		if (hC + curK * a) % dM != 0:
			curMoves += 1
		if curMoves * (dC + (k - curK) * w) >= hM:
			return 'YES'
	return 'NO'

def main():
	T = int(input())
	while T > 0:
		(hC, dC, hM, dM, k, w, a) = Input()
		print(Solve(hC, dC, hM, dM, k, a, w))
		T = T - 1
main()


import sys

def main():
	t = int(input())
	for _ in range(t):
		(hc, dc) = map(int, input().split())
		(hm, dm) = map(int, input().split())
		(k, w, a) = map(int, input().split())
		for i in range(k + 1):
			nhc = hc + i * a
			ndc = dc + (k - i) * w
			if (hm + ndc - 1) // ndc <= (nhc + dm - 1) // dm:
				sys.stdout.write('YES\n')
				break
		else:
			sys.stdout.write('NO\n')
main()


def tList():
	a = map(int, input().split())
	return a
import math

def solve():
	for _ in range(int(input())):
		(hc, dc) = tList()
		(hm, dm) = tList()
		(k, m, a) = tList()
		for i in range(k + 1):
			h = hc + a * i
			d = dc + m * (k - i)
			r = [(hm + d - 1) // d, (h + dm - 1) // dm]
			if r[0] <= r[1]:
				print('YES')
				break
		else:
			print('NO')
solve()


t = int(input())
for i in range(t):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	win = False
	for j in range(k + 1):
		monster_die = (hm - 1) // (dc + j * w) + 1
		char_die = (hc + (k - j) * a - 1) // dm + 1
		if monster_die <= char_die:
			win = True
			break
	if win:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	dc += w * k
	for m_h in range(k + 1):
		if (hc + dm - 1) // dm >= (hm + dc - 1) // dc:
			print('YES')
			break
		hc += a
		dc -= w
	else:
		print('NO')


def help(a, b, x, y, k, at, h, spend):
	t1 = a + h * spend
	t2 = b + at * (k - spend)
	if x % t2 == 0:
		temp1 = x // t2
	else:
		temp1 = x // t2 + 1
	if t1 % y == 0:
		temp2 = t1 // y
	else:
		temp2 = t1 // y + 1
	if temp1 <= temp2:
		return True
	return False
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(x, y) = map(int, input().split())
	(k, at, h) = map(int, input().split())
	if x % b == 0:
		player = x // b
	else:
		player = x // b + 1
	if a % y == 0:
		monster = a // y
	else:
		monster = a // y + 1
	if player <= monster:
		print('YES')
	else:
		flag = 0
		for i in range(k + 1):
			if help(a, b, x, y, k, at, h, i):
				flag = 1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


from math import ceil

def solve():
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	for i in range(k + 1):
		nhc = hc + a * (k - i)
		ndc = dc + w * i
		if ceil(nhc / dm) >= ceil(hm / ndc):
			print('YES')
			return
	print('NO')
t = int(input())
while t:
	solve()
	t = t - 1


import math

def ans(h1, a1, h, a, k, h2, a2):
	i = 0
	j = 11
	while i <= k:
		if math.ceil(h2 / (a1 + (k - i) * a)) <= math.ceil((h1 + h * i) / a2):
			j = 10
			break
		else:
			j = 12
			i = i + 1
	if j == 12:
		print('NO')
	elif j == 10:
		print('YES')
t = 0
yy = int(input())
while t < yy:
	(h1, a1) = input().split()
	(h2, a2) = input().split()
	(k, a, h) = input().split()
	ans(int(h1), int(a1), int(h), int(a), int(k), int(h2), int(a2))
	t = t + 1


tc = int(input())
for i in range(tc):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	AA = hm // dc + (hm % dc != 0)
	bb = hc // dm + (hc % dm != 0)
	if AA <= bb:
		print('YES')
		continue
	ok = False
	for i in range(k + 1):
		A = hm // (dc + w * i) + (hm % (dc + w * i) != 0)
		b = (hc + a * (k - i)) // dm + ((hc + a * (k - i)) % dm != 0)
		if A <= b:
			print('YES')
			ok = True
			break
	if ok:
		continue
	print('NO')


test = int(input())
for _ in range(test):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	ans = 'NO'
	for i in range(k + 1):
		nhc = hc + i * a
		ndc = dc + (k - i) * w
		if -(-hm // ndc) <= -(-nhc // dm):
			ans = 'YES'
			break
	print(ans)


def canwin(hc, dc, hm, dm):
	mshots = hc // dm
	if hc % dm > 0:
		mshots += 1
	if mshots * dc >= hm:
		return True
	return False
nrI = int(input())
for i in range(nrI):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	wins = False
	for buya in range(k + 1):
		if canwin(hc + buya * a, dc + (k - buya) * w, hm, dm):
			wins = True
			break
	if wins:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	for x in range(k + 1):
		if (hc + a * x - 1) // dm + 1 >= (hm - 1) // (dc + w * (k - x)) + 1:
			print('YES')
			break
	else:
		print('NO')


def fun(t):
	for i in range(t):
		(hc, dc) = map(int, input().split())
		(hm, dm) = map(int, input().split())
		(k, w, a) = map(int, input().split())
		done = 0
		for i in range(k + 1):
			if hm // (w * i + dc) + (hm % (w * i + dc) != 0) <= (hc + a * (k - i)) // dm + ((hc + a * (k - i)) % dm != 0):
				done = 1
				print('YES')
				break
		if done == 0:
			print('NO')
t = int(input())
fun(t)


for _ in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	if hm * dm <= hc * dc:
		print('YES')
	else:
		f = 0
		for i in range(k + 1):
			s = dc + i * w
			c = hc + (k - i) * a
			if hm % s == 0:
				s1 = hm // s
			else:
				s1 = hm // s + 1
			if c % dm == 0:
				c1 = c // dm
			else:
				c1 = c // dm + 1
			if s1 <= c1:
				f = 1
				break
		if f == 1:
			print('YES')
		else:
			print('NO')


def wins(dc, hc, dm, hm):
	surv_m = (hm + dc - 1) // dc
	surv_c = (hc + dm - 1) // dm
	return surv_c >= surv_m

def solve():
	(hc, dc) = [int(x) for x in input().split()]
	(hm, dm) = [int(x) for x in input().split()]
	(k, w, a) = [int(x) for x in input().split()]
	for kk in range(0, k + 1):
		if wins(dc + kk * w, hc + (k - kk) * a, dm, hm):
			return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	print(solve())


def mata_monstro(hc, hm, dc, dm, moedas, atkUp, defUp):
	mortec = -(-hc // dm)
	mortem = -(-hm // dc)
	if mortec >= mortem:
		return True
	for j in range(moedas + 1):
		mortecnova = -(-(hc + j * defUp) // dm)
		mortemnova = -(-hm // (dc + (moedas - j) * atkUp))
		if mortecnova >= mortemnova:
			return True
	return False

def main():
	n = int(input())
	for i in range(n):
		entrada = input().split()
		hc = int(entrada[0])
		dc = int(entrada[1])
		entrada = input().split()
		hm = int(entrada[0])
		dm = int(entrada[1])
		entrada = input().split()
		moedas = int(entrada[0])
		atkUp = int(entrada[1])
		defUp = int(entrada[2])
		if mata_monstro(hc, hm, dc, dm, moedas, atkUp, defUp):
			print('YES')
		else:
			print('NO')
main()


def fight(hc, dc, hm, dm):
	character = (hm + dc - 1) // dc
	monster = (hc + dm - 1) // dm
	return character <= monster

def main():
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	for i in range(k + 1):
		if fight(hc + i * a, dc + (k - i) * w, hm, dm):
			print('YES')
			return
	print('NO')
t = int(input())
for _ in range(t):
	main()


def solve():
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	for i in range(k + 1):
		ch = hc + a * i
		cd = dc + w * (k - i)
		if ch - dm * ((hm + cd - 1) // cd - 1) > 0:
			print('YES')
			return
	print('NO')
t = int(input())
while t:
	t -= 1
	solve()


t = int(input())
for _ in range(t):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	f = False
	for i in range(k + 1):
		udc = i * w + dc
		uhc = (k - i) * a + hc
		turns = (hm + udc - 1) // udc
		turns1 = (uhc + dm - 1) // dm
		if turns <= turns1:
			f = True
			break
	if f:
		print('YES')
	else:
		print('NO')


from math import ceil
for _ in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	flag = 0
	for i in range(k + 1):
		hc1 = hc + i * a
		dc1 = dc + (k - i) * w
		step1 = ceil(hm / dc1)
		step2 = ceil(hc1 / dm)
		if step1 <= step2:
			flag = 1
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for q in range(t):
	(H, D) = map(int, input().split())
	(h, d) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	turns_p = (h + D - 1) // D
	turns_m = (H + d - 1) // d
	if turns_p <= turns_m:
		print('YES')
	else:
		flag = True
		for x in range(k + 1):
			y = k - x
			n = (h + (D + x * w) - 1) // (D + x * w)
			m = (H + y * a + d - 1) // d
			if n <= m:
				print('YES')
				flag = False
				break
		if flag:
			print('NO')


for _ in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	b = 0
	for i in range(k + 1):
		x = (hm - 1) // (dc + w * i)
		y = (hc - 1 + a * (k - i)) // dm
		if x <= y:
			print('YES')
			b = 1
			break
	if b == 0:
		print('NO')


for i in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())

	def battle(hc, dc, hm, dm, k, a, w):
		for i in range(0, k + 1):
			(hc1, dc1) = (hc + i * w, dc + (k - i) * a)
			h = -(-hm // dc1)
			m = -(-hc1 // dm)
			if m >= h:
				return 'YES'
		return 'NO'
	print(battle(hc, dc, hm, dm, k, w, a))


for _ in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(coin, weapon, armor) = map(int, input().split())
	flag = 0
	for i in range(coin + 1):
		tdc = dc + i * weapon
		thc = hc + (coin - i) * armor
		v1 = -(-hm // tdc)
		v2 = -(-thc // dm)
		if v1 <= v2:
			flag = 1
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


def solve():
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(coin, weap, armor) = map(int, input().split())
	fl = 0
	for i in range(coin + 1):
		tdc = dc + i * weap
		thc = hc + (coin - i) * armor
		v1 = -(-hm // tdc)
		v2 = -(-thc // dm)
		if v1 <= v2:
			fl = 1
			break
	if fl == 1:
		print('YES')
	else:
		print('NO')
t = int(input())
while t:
	solve()
	t -= 1


for _ in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	for i in range(k + 1):
		h = hc + i * a
		d = dc + (k - i) * w
		cnt = hm // d
		if hm % d:
			cnt += 1
		if (cnt - 1) * dm < h:
			print('YES')
			break
	else:
		print('NO')


for _ in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	res = 'NO'
	for i in range(k + 1):
		if ((hc + i * a - 1) // dm + 1) * (dc + (k - i) * w) >= hm:
			res = 'YES'
			break
	print(res)


t = int(input())
for i in range(t):
	s = 0
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	if k == 0:
		if dc * -(-hc // dm) >= hm:
			print('YES')
			s = 1
			continue
		else:
			k = -1
	for j in range(k + 1):
		if (dc + (k - j) * w) * int((hc + j * a) / dm + 0.999) >= hm:
			print('YES')
			s = 1
			break
	if s == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	ans = 'NO'
	for i in range(k + 1):
		hcn = hc + i * a
		dcn = dc + (k - i) * w
		if (hm + dcn - 1) // dcn <= (hcn - 1 + dm) // dm:
			ans = 'YES'
			break
	print(ans)


def floorDiv(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1
for T in range(int(input())):
	(h_c, d_c) = map(int, input().split(' '))
	(h_m, d_m) = map(int, input().split(' '))
	(k, a, w) = map(int, input().split(' '))
	d_c += a * k
	while k >= 0:
		if floorDiv(h_m, d_c) <= floorDiv(h_c, d_m):
			print('YES')
			break
		else:
			d_c -= a
			h_c += w
		k -= 1
	if k < 0:
		print('NO')


z = int(input())
from math import ceil
for i in range(z):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	p = ceil(hc / dm)
	m = ceil(hm / dc)
	if p >= m:
		print('YES')
	else:
		t = True
		for i in range(0, k + 1):
			if ceil((hc + i * a) / dm) >= ceil(hm / (dc + (k - i) * w)):
				t = False
				break
		if t == True:
			print('NO')
		else:
			print('YES')


t = int(input())
for _ in range(t):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	is_ans = False
	for i in range(k + 1):
		ndc = dc + i * w
		nhc = hc + (k - i) * a
		if (hm + ndc - 1) // ndc <= (nhc + dm - 1) // dm:
			is_ans = True
			break
	if is_ans:
		print('YES')
	else:
		print('NO')


from math import ceil
R = lambda : map(int, input().split())
for j in range(int(input())):
	(hc, dc) = R()
	(hm, dm) = R()
	(k, w, a) = R()
	for i in range(k + 1):
		if ceil(hm / (dc + (k - i) * w)) <= ceil((hc + i * a) / dm):
			print('YES')
			break
	else:
		print('NO')


import sys
import math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_ls():
	return list(map(int, sys.stdin.readline().strip().split()))

def test_ok(ok):
	print('YES' if ok else 'NO')

def main():
	for _ in range(int(input())):
		(hc, dc) = map(int, input().split())
		(hm, dm) = map(int, input().split())
		(k, w, a) = map(int, input().split())
		ok = False
		for i in range(k + 1):
			new_hc = hc + i * a
			new_dc = dc + (k - i) * w
			x = hm // new_dc
			if hm % new_dc > 0:
				x += 1
			y = new_hc // dm
			if new_hc % dm > 0:
				y += 1
			if x <= y:
				ok = True
				break
		test_ok(ok)
main()


from sys import stdin
from math import ceil

def check(hc, hm, dc, dm, k, w, a):
	for i in range(k + 1):
		val1 = ceil((hc + (k - i) * a) / dm)
		val2 = ceil(hm / (dc + i * w))
		if val1 >= val2:
			return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	print(check(hc, hm, dc, dm, k, w, a))


t = int(input())
while t:
	test = 0
	t -= 1
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	for i in range(0, k + 1):
		weap = i * w
		arm = (k - i) * a
		newhc = hc + arm
		newdc = dc + weap
		attacks = hm // newdc
		if hm % newdc != 0:
			attacks += 1
		att_m = attacks - 1
		if newhc - dm * att_m > 0:
			print('YES')
			test = 1
			break
	if test == 0:
		print('NO')


import math
T = int(input())

def solve(i):
	(hc, dc) = list(map(int, input().split(' ')))
	(hm, dm) = list(map(int, input().split(' ')))
	(c, du, hu) = list(map(int, input().split(' ')))
	for i in range(c + 1):
		nhc = hc + i * hu
		ndc = dc + (c - i) * du
		if (hm + ndc - 1) // ndc <= (nhc + dm - 1) // dm:
			print('YES')
			return
	print('NO')
for i in range(T):
	solve(i)


from math import ceil

def turns(attack, health):
	if health % attack == 0:
		return health // attack
	return ceil(health / attack)

def does_win(ha, hh, ma, mh):
	hturns = turns(ha, mh)
	mturns = turns(ma, hh)
	return hturns <= mturns

def can_spend(ha, hh, ma, mh, k, w, a):
	for wk in range(k + 1):
		if does_win(ha + wk * w, hh + (k - wk) * a, ma, mh):
			return True
	return False

def main():
	ncases = int(input())
	for i in range(ncases):
		(hh, ha) = input().split()
		(mh, ma) = input().split()
		(k, w, a) = input().split()
		if can_spend(int(ha), int(hh), int(ma), int(mh), int(k), int(w), int(a)):
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	(hc, dc) = [int(i) for i in input().split()]
	(hm, dm) = [int(i) for i in input().split()]
	(k, w, a) = [int(i) for i in input().split()]
	flag = 0
	for i in range(k + 1):
		if (hm - 1) // (dc + i * w) <= (hc + (k - i) * a - 1) // dm:
			flag = 1
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	raw = input().split()
	(A, B) = (int(raw[0]), int(raw[1]))
	raw = input().split()
	(C, D) = (int(raw[0]), int(raw[1]))
	raw = input().split()
	(k, w, a) = (int(raw[0]), int(raw[1]), int(raw[2]))
	ok = False
	for i in range(k + 1):
		x = A + i * a
		y = B + (k - i) * w
		if (C + y - 1) // y <= (x + D - 1) // D:
			ok = True
			break
	print('YES' if ok else 'NO')


import math
T = int(input())
for i in range(T):
	(h_c, d_c) = map(int, input().split())
	(h_m, d_m) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	for i in range(k + 1):
		if math.ceil(h_m / (d_c + (k - i) * w)) <= math.ceil((h_c + i * a) / d_m):
			print('YES')
			break
		elif i == k:
			print('NO')


t = int(input())
for T in range(t):
	(hc, dc) = [int(x) for x in input().split()]
	(hm, dm) = [int(x) for x in input().split()]
	(k, w, a) = [int(x) for x in input().split()]
	ans = 'NO'
	k1 = k
	while k1 >= 0:
		hc1 = hc + (k - k1) * a
		dc1 = dc + k1 * w
		ce = hc1 // dm
		if hc1 % dm != 0:
			ce += 1
		me = hm // dc1
		if hm % dc1 != 0:
			me += 1
		if ce >= me:
			ans = 'YES'
			break
		k1 -= 1
	print(ans)


import math
for t in range(int(input())):
	(ch, cd) = map(int, input().split())
	(mh, md) = map(int, input().split())
	(k, a, d) = map(int, input().split())
	flag = False
	for i in range(k + 1):
		rounds = math.ceil((i * d + ch) / md)
		atk = cd + (k - i) * a
		if rounds * atk >= mh:
			print('YES')
			flag = True
			break
	if not flag:
		print('NO')


from math import ceil
for _ in range(int(input())):
	(hc, dc) = map(int, input().split())
	(hm, dm) = map(int, input().split())
	(k, w, a) = map(int, input().split())
	ans = 'NO'
	for i in range(0, k + 1):
		chr = ceil((hc + (k - i) * a) / dm)
		mon = ceil(hm / (dc + i * w))
		if chr >= mon:
			ans = 'YES'
			break
	print(ans)