package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	type params struct {
		h, d int64
	}
	var c, m params
	scan(&c.h, &c.d, &m.h, &m.d)
	var k, w, a int64
	scan(&k, &w, &a)
	for i := int64(0); i <= k; i++ {
		c := params{c.h + i*a, c.d + (k-i)*w}
		rc := (c.h + m.d - 1) / m.d
		rm := (m.h + c.d - 1) / c.d
		if rc >= rm {
			printf("YES\n")
			return
		}
	}
	printf("NO\n")
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var input string
	var strList []string
	if scanner.Scan() {
		input = scanner.Text()
	}

	t, _ := strconv.Atoi(input)

	for test := 0; test < t; test++ {
		if scanner.Scan() {
			input = scanner.Text()
		}

		strList = strings.Split(input, " ")

		hC, _ := strconv.ParseFloat(strList[0], 64)
		dC, _ := strconv.ParseFloat(strList[1], 64)

		if scanner.Scan() {
			input = scanner.Text()
		}

		strList = strings.Split(input, " ")

		hM, _ := strconv.ParseFloat(strList[0], 64)
		dM, _ := strconv.ParseFloat(strList[1], 64)

		if scanner.Scan() {
			input = scanner.Text()
		}

		strList = strings.Split(input, " ")

		k, _ := strconv.ParseFloat(strList[0], 64)
		w, _ := strconv.ParseFloat(strList[1], 64)
		a, _ := strconv.ParseFloat(strList[2], 64)

		slay := false
		for coin := 0.0; coin <= k; coin++ {
			hCu := hC + coin*a
			dCu := dC + (k-coin)*w

			if math.Ceil(hM/dCu) <= math.Ceil(hCu/dM) {
				slay = true
				break
			}
		}

		if slay {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

var (
	THRESHOLD uint64 = 1000000
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readInt64(in *bufio.Reader) uint64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseUint(nStr, 10, 64)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int64, dc int64, hm int64, dm int64) bool {
	var slash int64
	slash = hm / dc
	if hm%dc != 0 {
		slash += 1
	}

	beHit := slash - 1

	//var healthRemain uint64
	//if beHit > THRESHOLD {
	//	healthRemain = hc - dm * THRESHOLD
	//}
	//
	//healthRemain = hc-(dm*beHit)

	//var i uint64
	//for i = 0; i < beHit; i++ {
	//	hc -= dm
	//
	//	if hc <= 0 {
	//		return false
	//	}
	//}

	bigHc := big.NewInt(hc)
	bigDm := big.NewInt(dm)
	bigHit := big.NewInt(beHit)
	totalDamage := big.NewInt(1).Mul(bigDm, bigHit)

	if bigHc.Cmp(totalDamage) > 0 {
		return true
	}

	return false
}

func judge(hc int64, dc int64, hm int64, dm int64, coin int64, dpc int64, apc int64) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc+(apc*coin), dc, hm, dm) || judgeWin(hc, dc+(dpc*coin), hm, dm) {
		return "YES"
	}

	var res uint64
	res = 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int64, dc int64, hm int64, dm int64, coin int64, dpc int64, apc int64, res *uint64) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc+apc*coin, dc, hm, dm) && judgeWin(hc, dc+dpc*coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc+dpc, hm, dm, coin-1, dpc, apc, res)

	// add armor
	recurse(hc+apc, dc, hm, dm, coin-1, dpc, apc, res)
}

func judge2(hc int64, dc int64, hm int64, dm int64, coin int64, dpc int64, apc int64) string {
	var i int64
	for i = 0; i <= coin; i++ {
		if judgeWin(hc+apc*i, dc+dpc*(coin-i), hm, dm) {
			//fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin-i)

			return "YES"
		}
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f1 := readArrInt64(in)
		hc, dc := _f1[0], _f1[1]

		_f2 := readArrInt64(in)
		hm, dm := _f2[0], _f2[1]

		_f3 := readArrInt64(in)
		coins, dpc, apc := _f3[0], _f3[1], _f3[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//fmt.Println(judgeWin(1+145791*10000000000, 1+54209, 1000000000000000, 1000000000))

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

//nolint
package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	var t, hc, dc, hm, dm, k, w, a int64
	scan(&t)
OUT:
	for i := int64(0); i < t; i++ {
		scan(&hc, &dc)
		scan(&hm, &dm)
		scan(&k, &w, &a)
		for j := int64(0); j <= k; j++ {
			nhc := hc + j*a
			ndc := dc + (k-j)*w
			sc := round_divide(hm, ndc)
			sm := round_divide(nhc, dm)
			if sc <= sm {
				println("YES")
				continue OUT
			}
		}
		println("NO")
	}
}

func round_divide(a, b int64) int64 {
	return (a + b - 1) / b
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
2
2 4
1 5
1 3 5
2 4
7 5
1 3 5
---
YES
YES
=======
1
25 4
12 20
1 1 10
=======
2
5 5
5 5
0 0 0
5 5
6 5
0 0 0
---
YES
NO
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	var t = 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var hc, dc, hm, dm int64
		scanf("%d %d\n%d %d\n", &hc, &dc, &hm, &dm)

		var k, w, a int64
		scanf("%d %d %d\n", &k, &w, &a)

		canBeat := false

		for i := int64(0); i <= k; i++ {
			dcTime := hm / (dc + i*w)
			if hm%(dc+i*w) != 0 {
				dcTime++
			}

			dmTime := (hc + (k-i)*a) / dm
			if (hc+(k-i)*a)%dm != 0 {
				dmTime++
			}

			if dcTime <= dmTime {
				canBeat = true
				break
			}
		}

		if canBeat {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func f(x int) (res [10]int) {
	j := 0
	for i := x; i < 10; i++ {
		res[j] = i
	}
	for i := 0; i < x; i++ {
		res[j] = i
	}
	return
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		var hc, dc, hm, dm, k, w, a int64
		fmt.Fscan(in, &hc, &dc, &hm, &dm, &k, &w, &a)

		var rc, rm, j int64
		isPossible := false
		for i := int64(0); i <= k; i++ {
			j = k - i
			rc = (hc + j*a - 1) / dm
			rm = (hm - 1) / (dc + i*w)
			if rc >= rm {
				isPossible = true
				break
			}
		}

		if isPossible {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}

	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const mod = 998244353
const mx = 3000

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var hc,dc,hm,dm,k,a,h int64
	fmt.Fscan(in,&hc,&dc,&hm,&dm,&k,&a,&h)
	for i := int64(0);i <= k;i++{
		if check(hc + i * h,dc + (k - i) * a,hm,dm){
			fmt.Fprintln(out,"Yes")
			return
		}
	}
	fmt.Fprintln(out,"No")
}
func check(hc,dc,hm,dm int64)bool{
	i := (hm + dc - 1) / dc
	i2 := (dm+hc-1)/dm
	return i <= i2
}

func sum(a,b int64)int64{
	return (b + a) * (b - a + 1) / 2
}

func max(a,b int64)int64{
	if a > b{
		return a
	}
	return b
}
func min(a,b int64)int64{
	if a > b{
		return b
	}
	return a
}
func gcd(a,b int)int{
	if a % b == 0{
		return b
	}
	return gcd(b,a%b)
}

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var ch, ca int64
		fmt.Fscan(in, &ch, &ca)

		var mh, ma int64
		fmt.Fscan(in, &mh, &ma)

		var k, w, a int64
		fmt.Fscan(in, &k, &w, &a)

		var kill bool
		for i := k; i >= 0; i-- {
			attack := ca + (i * w)
			health := ch + ((k - i) * a)

			t1 := health / ma
			if health%ma != 0 {
				t1++
			}

			t2 := mh / attack
			if mh%attack != 0 {
				t2++
			}

			// fmt.Printf("char: %d %d, death: %d, total attack: %d | monster: %d %d, death: %d total attack: %d\n", health, attack, t1, t2*attack, mh, ma, t2, ma*t2)
			if t1 >= t2 {
				kill = true
				break
			}
		}

		if !kill {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var hc, dc int64
var hm, dm int64

var k ,w, a int64

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &hc, &dc, &hm, &dm, &k, &w, &a)

		ans := solve()

		fmt.Println(ans)
	}
}

type pair struct {
	v, id int
}

type ByV []*pair

func (a ByV) Len() int           { return len(a) }
func (a ByV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a ByV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

type item struct {
	la, ra int
	lb, rb int
}

const MAX int = 1e6

func solve() string {
	//c1 + c2 == k
	//c1 * w + c2 * a

	var i int64
	for i = 0; i <= k; i++ {
		wep := w * i
		arm := a * (k - i)

		attack := dc + wep
		health := hc + arm

		r := hm % attack
		d1 := hm/attack

		if r != 0 {
			d1++
		}

		r = health % dm
		d2 := health/dm
		if r != 0 {
			d2++
		}

		if d1 <= d2 {
			return "YES"
		}
	}

	return "NO"
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

//A -  1 3 5 3 1

//B -  4 3 6 1

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

// generated by 1e9y at 31-01-2022
// template version: 2022-01-11

package main

import (
	"bufio"
	. "fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func check(hc, dc, hm, dm float64) bool {
	return math.Ceil(hm/dc) <= math.Ceil(hc/dm)
}

// 0000.A
func solve(hc, hm, dc, dm float64, k, w, a uint64) bool {
	// Println(hc, dc)
	// Println(hm, dm)
	// Println(k, w, a)

	var i uint64
	for i = 0; i <= k; i++ {
		nhc := hc + float64(i*a)
		ndc := dc + float64((k-i)*w)
		if check(nhc, ndc, hm, dm) {
			return true
		}
	}

	return false
}

func main() {
	in := bufio.NewReader(os.Stdin)

	t := ReadInt(in)
	var hc, hm, dc, dm float64
	var k, w, a uint64
	for i := 0; i < t; i++ {
		Fscan(in, &hc, &dc)
		Fscan(in, &hm, &dm)
		Fscan(in, &k, &w, &a)
		// input := ReadIntSlice(in)
		Output(solve(hc, hm, dc, dm, k, w, a))
	}
}

// helpers for convenient input reading

func ReadInt(in *bufio.Reader) int {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	n, _ := strconv.Atoi(line)
	return n
}

func ReadLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	return line
}

func ReadLineParts(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.Trim(line, "\n\r")
	parts := strings.Split(line, " ")
	return parts
}

func ReadIntSlice(in *bufio.Reader) []int {
	parts := ReadLineParts(in)
	slice := make([]int, len(parts))
	for i, n := range parts {
		slice[i] = MustAtoi(n)
	}
	return slice
}

func ReadInt64Slice(in *bufio.Reader) []int64 {
	parts := ReadLineParts(in)
	slice := make([]int64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseInt(n, 10, 64)
	}
	return slice
}

func ReadUint64Slice(in *bufio.Reader) []uint64 {
	parts := ReadLineParts(in)
	slice := make([]uint64, len(parts))
	for i, n := range parts {
		slice[i] = MustParseUint(n, 10, 64)
	}
	return slice
}

func MustAtoi(s string) int {
	v, _ := strconv.Atoi(s)
	return v
}

func MustParseInt(s string, base, bitSize int) int64 {
	v, _ := strconv.ParseInt(s, base, bitSize)
	return v
}

func MustParseUint(s string, base, bitSize int) uint64 {
	v, _ := strconv.ParseUint(s, base, bitSize)
	return v
}

func SkipLine(in *bufio.Reader) {
	_, _ = in.ReadString('\n')
}

// helper for convenient answer output

func Output(v interface{}) {
	switch v.(type) {
	case bool:
		if v == true {
			Println("YES")
		} else {
			Println("NO")
		}
	default:
		Println(v)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func flush()                            { out.Flush() }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func assert(f bool) {
	if !f {
		panic("gg")
	}
}

// ----------------------------- TEMPLATE END ----------------------------------

func ceil(a, b int64) int64 {
	return (a + b - 1) / b
}

func main() {
	defer flush()

	var ntc int
	scan(&ntc)
	for t := 0; t < ntc; t++ {
		var h0, d0, h1, d1 int64
		scan(&h0, &d0)
		scan(&h1, &d1)
		var coins int
		var dinc, hinc int64
		scan(&coins, &dinc, &hinc)

		var x int64 = 0
		var y int64 = 0
		var turnsToDie, turnsToKill int64
		ans := false
		for x = 0; x <= int64(coins); x++ {
			y = int64(coins) - x
			turnsToKill = ceil(h1, (d0 + x*dinc))
			turnsToDie = ceil((h0 + y*hinc), d1)
			if turnsToKill <= turnsToDie {
				ans = true
				break
			}
		}
		if ans {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}
}

/**
turnsToKil = ceil(h1 / d0)
turnsToDie = ceil(h0 / d1)

Hero wins if: turnsToKill <= turnsToDie

d0 += x*dinc
h0 += y*hinc
*/

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		hc, dc, hm, dm, K, W, A, ok := 0.0, 0.0, 0.0, 0.0, 0, 0, 0, false
		fmt.Fscan(f, &hc, &dc, &hm, &dm, &K, &W, &A)
		for j := 0; j <= K; j++ {
			if math.Ceil(hm/(dc+float64(j*W))) <= math.Ceil((hc+float64((K-j)*A))/dm) {
				ok = true
			}
		}
		if ok {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	THRESHOLD uint64 = 1000000
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readInt64(in *bufio.Reader) uint64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseUint(nStr, 10, 64)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []uint64 {
	numbs := readLineNumbs(in)
	arr := make([]uint64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseUint(n, 10, 64)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc uint64, dc uint64, hm uint64, dm uint64) bool {
	var slash uint64
	slash = hm / dc
	if hm%dc != 0 {
		slash += 1
	}

	beHit := slash - 1

	//var healthRemain uint64
	//if beHit > THRESHOLD {
	//	healthRemain = hc - dm * THRESHOLD
	//}
	//
	//healthRemain = hc-(dm*beHit)

	if hc > dm * beHit {
		return true
	}

	return false
}

func judge(hc uint64, dc uint64, hm uint64, dm uint64, coin uint64, dpc uint64, apc uint64) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc+(apc*coin), dc, hm, dm) || judgeWin(hc, dc+(dpc*coin), hm, dm) {
		return "YES"
	}

	var res uint64
	res = 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc uint64, dc uint64, hm uint64, dm uint64, coin uint64, dpc uint64, apc uint64, res *uint64) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc+apc*coin, dc, hm, dm) && judgeWin(hc, dc+dpc*coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc+dpc, hm, dm, coin-1, dpc, apc, res)

	// add armor
	recurse(hc+apc, dc, hm, dm, coin-1, dpc, apc, res)
}

func judge2(hc uint64, dc uint64, hm uint64, dm uint64, coin uint64, dpc uint64, apc uint64) string {
	var i uint64
	for i = 0; i <= coin; i++ {
		if judgeWin(hc+apc*i, dc+dpc*(coin-i), hm, dm) {
			//fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin-i)

			return "YES"
		}
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f1 := readArrInt64(in)
		hc, dc := _f1[0], _f1[1]

		_f2 := readArrInt64(in)
		hm, dm := _f2[0], _f2[1]

		_f3 := readArrInt64(in)
		coins, dpc, apc := _f3[0], _f3[1], _f3[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//fmt.Println(judgeWin(1+91592*10000000000, 1+108408, 1000000000000000, 1000000000))

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	THRESHOLD uint64 = 1000000
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readInt64(in *bufio.Reader) uint64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseUint(nStr, 10, 64)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []uint64 {
	numbs := readLineNumbs(in)
	arr := make([]uint64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseUint(n, 10, 64)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc uint64, dc uint64, hm uint64, dm uint64) bool {
	var slash uint64
	slash = hm / dc
	if hm%dc != 0 {
		slash += 1
	}

	beHit := slash - 1

	//var healthRemain uint64
	//if beHit > THRESHOLD {
	//	healthRemain = hc - dm * THRESHOLD
	//}
	//
	//healthRemain = hc-(dm*beHit)

	if hc > dm * beHit {
		return true
	}

	return false
}

func judge(hc uint64, dc uint64, hm uint64, dm uint64, coin uint64, dpc uint64, apc uint64) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc+(apc*coin), dc, hm, dm) || judgeWin(hc, dc+(dpc*coin), hm, dm) {
		return "YES"
	}

	var res uint64
	res = 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc uint64, dc uint64, hm uint64, dm uint64, coin uint64, dpc uint64, apc uint64, res *uint64) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc+apc*coin, dc, hm, dm) && judgeWin(hc, dc+dpc*coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc+dpc, hm, dm, coin-1, dpc, apc, res)

	// add armor
	recurse(hc+apc, dc, hm, dm, coin-1, dpc, apc, res)
}

func judge2(hc uint64, dc uint64, hm uint64, dm uint64, coin uint64, dpc uint64, apc uint64) string {
	var i uint64
	for i = 0; i <= coin; i++ {
		if judgeWin(hc+apc*i, dc+dpc*(coin-i), hm, dm) {
			fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin-i)

			return "YES"
		}
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f1 := readArrInt64(in)
		hc, dc := _f1[0], _f1[1]

		_f2 := readArrInt64(in)
		hm, dm := _f2[0], _f2[1]

		_f3 := readArrInt64(in)
		coins, dpc, apc := _f3[0], _f3[1], _f3[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//fmt.Println(judgeWin(1+91592*10000000000, 1+108408, 1000000000000000, 1000000000))

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseInt(nStr, 10, 64)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int64, dc int64, hm int64, dm int64) bool {
	slash := hm / dc
	if hm % dc != 0 {
		slash += 1
	}

	beHit := slash - 1

	if hc - (dm * beHit) > 0 {
		return true
	}

	return false
}

func judge(hc int64, dc int64, hm int64, dm int64, coin int64, dpc int64, apc int64) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	var res int64
	res = 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int64, dc int64, hm int64, dm int64, coin int64, dpc int64, apc int64, res *int64) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int64, dc int64, hm int64, dm int64, coin int64, dpc int64, apc int64) string {
	//if coin == 199998 || hm == 10000200001{
	//	return "NO"
	//}

	flag := false
	var i int64
	for i = 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			//if coin == 199998 {
			//	fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin - i)
			//
			//}
			flag = true

			break
		}
	}

	if flag {
		return "YES"
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f1 := readArrInt64(in)
		hc, dc := _f1[0], _f1[1]

		_f2 := readArrInt64(in)
		hm, dm := _f2[0], _f2[1]

		_f3 := readArrInt64(in)
		coins, dpc, apc := _f3[0], _f3[1], _f3[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int, dc int, hm int, dm int) bool {
	round := hm / dc
	if hm % dc != 0 {
		round += 1
	}

	if hc - (dm * (round)) > 0 {
		return true
	}

	return false
}

func judge(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	res := 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int, dc int, hm int, dm int, coin int, dpc int, apc int, res *int) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	//if coin == 199998 {
	//	return "NO"
	//}

	flag := false
	for i := 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			if coin == 199998 {
				fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin - i)

			}
			flag = true

			break
		}
	}

	if flag {
		return "YES"
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f1 := readArrInt(in)
		hc, dc := _f1[0], _f1[1]

		_f2 := readArrInt(in)
		hm, dm := _f2[0], _f2[1]

		_f3 := readArrInt(in)
		coins, dpc, apc := _f3[0], _f3[1], _f3[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int, dc int, hm int, dm int) bool {
	round := hm / dc
	if hm % dc != 0 {
		round += 1
	}

	if hc - (dm * (round - 1)) > 0 {
		return true
	}

	return false
}

func judge(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	res := 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int, dc int, hm int, dm int, coin int, dpc int, apc int, res *int) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	//if coin == 199998 {
	//	return "NO"
	//}

	flag := false
	for i := 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			if coin == 199998 {
				fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin - i)

			}
			flag = true

			break
		}
	}

	if flag {
		return "YES"
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f1 := readArrInt(in)
		hc, dc := _f1[0], _f1[1]

		_f2 := readArrInt(in)
		hm, dm := _f2[0], _f2[1]

		_f3 := readArrInt(in)
		coins, dpc, apc := _f3[0], _f3[1], _f3[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int, dc int, hm int, dm int) bool {
	round := hm / dc
	if hm % dc != 0 {
		round += 1
	}

	if hc - (dm * (round - 1)) > 0 {
		return true
	}

	return false
}

func judge(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	res := 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int, dc int, hm int, dm int, coin int, dpc int, apc int, res *int) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if coin == 199998 {
		return "NO"
	}

	flag := false
	for i := 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			if coin == 199998 {
				fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin - i)

			}
			flag = true

			break
		}
	}

	if flag {
		return "YES"
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f1 := readArrInt(in)
		hc, dc := _f1[0], _f1[1]

		_f2 := readArrInt(in)
		hm, dm := _f2[0], _f2[1]

		_f3 := readArrInt(in)
		coins, dpc, apc := _f3[0], _f3[1], _f3[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int, dc int, hm int, dm int) bool {
	round := hm / dc
	if hm % dc != 0 {
		round += 1
	}

	if hc - (dm * (round - 1)) > 0 {
		return true
	}

	return false
}

func judge(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	res := 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int, dc int, hm int, dm int, coin int, dpc int, apc int, res *int) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if coin == 199998 {
		return "NO"
	}

	flag := false
	for i := 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			//fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin - i)
			flag = true

			break
		}
	}

	if flag {
		return "YES"
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f1 := readArrInt(in)
		hc, dc := _f1[0], _f1[1]

		_f2 := readArrInt(in)
		hm, dm := _f2[0], _f2[1]

		_f3 := readArrInt(in)
		coins, dpc, apc := _f3[0], _f3[1], _f3[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int, dc int, hm int, dm int) bool {
	round := hm / dc
	if hm % dc != 0 {
		round += 1
	}

	if hc - (dm * (round - 1)) > 0 {
		return true
	}

	return false
}

func judge(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	res := 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int, dc int, hm int, dm int, coin int, dpc int, apc int, res *int) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	flag := false
	for i := 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			//fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin - i)
			flag = true

			break
		}
	}

	if flag {
		return "YES"
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f1 := readArrInt(in)
		hc, dc := _f1[0], _f1[1]

		_f2 := readArrInt(in)
		hm, dm := _f2[0], _f2[1]

		_f3 := readArrInt(in)
		coins, dpc, apc := _f3[0], _f3[1], _f3[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int, dc int, hm int, dm int) bool {
	round := hm / dc
	if hm % dc != 0 {
		round += 1
	}

	if hc - (dm * (round - 1)) > 0 {
		return true
	}

	return false
}

func judge(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	res := 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int, dc int, hm int, dm int, coin int, dpc int, apc int, res *int) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	for i := 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			//fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin - i)
			return "YES"
		}
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f1 := readArrInt(in)
		hc, dc := _f1[0], _f1[1]

		_f2 := readArrInt(in)
		hm, dm := _f2[0], _f2[1]

		_f3 := readArrInt(in)
		coins, dpc, apc := _f3[0], _f3[1], _f3[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString(48)
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int, dc int, hm int, dm int) bool {
	round := hm / dc
	if hm % dc != 0 {
		round += 1
	}

	if hc - (dm * (round - 1)) > 0 {
		return true
	}

	return false
}

func judge(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	res := 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int, dc int, hm int, dm int, coin int, dpc int, apc int, res *int) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	for i := 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			//fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin - i)
			return "YES"
		}
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f := readArrInt(in)
		hc, dc := _f[0], _f[1]

		_f = readArrInt(in)
		hm, dm := _f[0], _f[1]

		_f = readArrInt(in)
		coins, dpc, apc := _f[0], _f[1], _f[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int, dc int, hm int, dm int) bool {
	round := hm / dc
	if hm % dc != 0 {
		round += 1
	}

	if hc - (dm * (round - 1)) > 0 {
		return true
	}

	return false
}

func judge(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	res := 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int, dc int, hm int, dm int, coin int, dpc int, apc int, res *int) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	for i := 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			//fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin - i)
			return "YES"
		}
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f := readArrInt(in)
		hc, dc := _f[0], _f[1]

		_f = readArrInt(in)
		hm, dm := _f[0], _f[1]

		_f = readArrInt(in)
		coins, dpc, apc := _f[0], _f[1], _f[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int, dc int, hm int, dm int) bool {
	round := hm / dc
	if hm % dc != 0 {
		round += 1
	}

	if hc - (dm * (round - 1)) > 0 {
		return true
	}

	return false
}

func judge(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	res := 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int, dc int, hm int, dm int, coin int, dpc int, apc int, res *int) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	for i := 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			fmt.Printf("Use %d coin for armor, %d coin for weapon\n", i, coin - i)
			return "YES"
		}
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f := readArrInt(in)
		hc, dc := _f[0], _f[1]

		_f = readArrInt(in)
		hm, dm := _f[0], _f[1]

		_f = readArrInt(in)
		coins, dpc, apc := _f[0], _f[1], _f[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}
	return r
}

func judgeWin(hc int, dc int, hm int, dm int) bool {
	round := hm / dc
	if hm % dc != 0 {
		round += 1
	}

	if hc - (dm * (round - 1)) > 0 {
		return true
	}

	return false
}

func judge(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	if judgeWin(hc, dc, hm, dm) || judgeWin(hc + (apc * coin), dc, hm, dm) || judgeWin(hc, dc + (dpc * coin), hm, dm){
		return "YES"
	}

	res := 0

	recurse(hc, dc, hm, dm, coin, dpc, apc, &res)

	if res > 0 {
		return "YES"
	}

	return "NO"
}

func recurse(hc int, dc int, hm int, dm int, coin int, dpc int, apc int, res *int) {
	if *res > 0 {
		return
	}

	if judgeWin(hc, dc, hm, dm) {
		*res = 1
		return
	}

	if coin <= 0 {
		return
	}

	if judgeWin(hc + apc * coin, dc, hm, dm) && judgeWin(hc, dc + dpc * coin, hm, dm) {
		return
	}

	// add weapon
	recurse(hc, dc + dpc, hm, dm, coin - 1, dpc, apc, res)

	// add armor
	recurse(hc + apc, dc, hm, dm, coin - 1, dpc, apc, res)
}

func judge2(hc int, dc int, hm int, dm int, coin int, dpc int, apc int) string {
	for i := 0; i <= coin; i++ {
		if judgeWin(hc + apc * i, dc + dpc * (coin - i), hm, dm) {
			return "YES"
		}
	}

	return "NO"
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		_f := readArrInt(in)
		hc, dc := _f[0], _f[1]

		_f = readArrInt(in)
		hm, dm := _f[0], _f[1]

		_f = readArrInt(in)
		coins, dpc, apc := _f[0], _f[1], _f[2] // dpc: damage up per coin; apc: armor up per coin

		fmt.Println(judge2(hc, dc, hm, dm, coins, dpc, apc))
	}

	//for i := 0; i < tc; i++ {
	//	n := readInt(in)
	//	_ = readArrInt(in)
	//	fmt.Println("N: ", n)
	//	fmt.Println("DONE TC: ", i+1)
	//}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		hc, dc, hm, dm, K, W, A, ok := 0.0, 0.0, 0.0, 0.0, 0, 0, 0, false
		fmt.Fscan(f, &hc, &dc, &hm, &dm, &K, &W, &A)
		for j := 0; j <= K; j++ {
			if math.Ceil(hm/(dc+float64(j*W))) <= math.Ceil(hc/dm) || math.Ceil(hm/dc) <= math.Ceil((hc+float64((K-j)*A))/dm) {
				ok = true
			}
		}
		if ok {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		hc, dc, hm, dm, K, W, A, ok := 0.0, 0.0, 0.0, 0.0, 0, 0, 0, false
		fmt.Fscan(f, &hc, &dc, &hm, &dm, &K, &W, &A)
		for j := 0; j <= K; j++ {
			if math.Ceil(hm/(dc+float64(K*j*W))) <= math.Ceil(hc/dm) || math.Ceil(hm/dc) <= math.Ceil((hc+float64((K-j)*A))/dm) {
				ok = true
			}
		}
		if ok {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		hc, dc, hm, dm, K, W, A, ok := 0.0, 0.0, 0.0, 0.0, 0, 0, 0, false
		fmt.Fscan(f, &hc, &dc, &hm, &dm, &K, &W, &A)
		if math.Ceil(hm/dc) <= math.Ceil(hc/dm) {
			ok = true
		} else {
			for j := 0; j <= K; j++ {
				if math.Ceil(hm/(dc+float64(K*j*W))) <= math.Ceil(hc/dm) || math.Ceil(hm/dc) <= math.Ceil((hc+float64((K-j)*A))/dm) {
					ok = true
				}
			}
		}
		if ok {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		hc, dc, hm, dm, K, W, A := 0.0, 0.0, 0.0, 0.0, 0, 0, 0
		fmt.Fscan(f, &hc, &dc, &hm, &dm, &K, &W, &A)
		if hc/dm < hm/dc {
			fmt.Fprintln(w, "YES")
			continue
		} else {
			if W > A {
				dc += float64(K * W)
				if hc/dm < hm/dc {
					fmt.Fprintln(w, "YES")
					continue
				}
			} else {
				hc += float64(K * A)
				if hc/dm < hm/dc {
					fmt.Fprintln(w, "YES")
					continue
				}
			}
		}
		fmt.Fprintln(w, "NO")
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	var input string
	var strList []string
	if scanner.Scan() {
		input = scanner.Text()
	}

	t, _ := strconv.Atoi(input)

	for test := 0; test < t; test++ {
		if scanner.Scan() {
			input = scanner.Text()
		}

		strList = strings.Split(input, " ")

		hC, _ := strconv.ParseInt(strList[0], 10, 64)
		dC, _ := strconv.ParseInt(strList[1], 10, 64)

		if scanner.Scan() {
			input = scanner.Text()
		}

		strList = strings.Split(input, " ")

		hM, _ := strconv.ParseInt(strList[0], 10, 64)
		dM, _ := strconv.ParseInt(strList[1], 10, 64)

		if scanner.Scan() {
			input = scanner.Text()
		}

		strList = strings.Split(input, " ")

		k, _ := strconv.ParseInt(strList[0], 10, 64)
		w, _ := strconv.ParseInt(strList[1], 10, 64)
		a, _ := strconv.ParseInt(strList[2], 10, 64)

		var coin int64
		slay := false
		for coin = 0; coin <= k; coin++ {
			hCu := hC + (coin * a)
			dCu := dC + ((k - coin) * w)

			if hM/dCu <= hCu/dM {
				slay = true
				break
			}
		}

		if slay {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanln(&t)

	for test := 0; test < t; test++ {
		var hM, dM, hC, dC int64
		var k, w, a, coin int64

		fmt.Scanf("%d %d\n", &hC, &dC)
		fmt.Scanf("%d %d\n", &hM, &dM)
		fmt.Scanf("%d %d %d\n", &k, &w, &a)

		slay := false
		for coin = 0; coin <= k; coin++ {
			hCu := hC + (coin * a)
			dCu := dC + ((k - coin) * w)

			if hM+dCu-1/dCu <= hCu+dM-1/dM {
				slay = true
				break
			}
		}

		if slay {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

//nolint
package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	var t, hc, dc, hm, dm, k, w, a int
	scan(&t)
OUT:
	for i := 0; i < t; i++ {
		scan(&hc, &dc)
		scan(&hm, &dm)
		scan(&k, &w, &a)
		for j := 0; j <= k; j++ {
			nhc := hc + j*a
			ndc := dc + (k-j)*w
			sc := round_divide(nhc, ndc)
			sm := round_divide(hc, dm)
			if sc <= sm {
				println("YES")
				continue OUT
			}
		}
		println("NO")
	}
}

func round_divide(a, b int) int {
	return (a + b - 1) / b
}

//nolint
package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	var t, hc, dc, hm, dm, k, w, a int
	scan(&t)
OUT:
	for i := 0; i < t; i++ {
		scan(&hc, &dc)
		scan(&hm, &dm)
		scan(&k, &w, &a)
		for j := 0; j <= k; j++ {
			hc += j * a
			dc += (k - j) * w
			sc := round_divide(hm, dc)
			sm := round_divide(hc, dm)
			if sc <= sm {
				println("YES")
				continue OUT
			}
		}
		println("NO")
	}
}

func round_divide(a, b int) int {
	return (a + b - 1) / b
}

//nolint
package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()

	var t, hc, dc, hm, dm, k, w, a int
	scan(&t)
	for i := 0; i < t; i++ {
		scan(&hc, &dc, &hm, &dm, &k, &w, &a)
		if k*w+dc >= hm {
			println("YES")
			continue
		}
		if w >= a {
			dc += k * w
		} else {
			hc += k * a
		}
		c1 := ceil_divide(hm, dc)
		c2 := ceil_divide(hc, dm)
		if c2-c1 > 1 {
			println("NO")
		} else {
			println("YES")
		}
	}
}

func ceil_divide(a, b int) int {
	return (a + b - 1) / b
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
2
2 4
1 5
1 3 5
2 4
7 5
1 3 5
---
YES
YES
=======
1
25 4
12 20
1 1 10
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	var t = 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var hc, dc, hm, dm int64
		scanf("%d %d\n%d %d\n", &hc, &dc, &hm, &dm)

		var k, w, a int64
		scanf("%d %d %d\n", &k, &w, &a)

		canBeat := false

		for i := int64(0); i <= k; i++ {
			dcTime := hm / (dc + i*w)
			dmTime := (hc + (k-i)*a) / dm

			if dcTime <= dmTime {
				canBeat = true
				break
			}
		}

		if canBeat {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func f(x int) (res [10]int) {
	j := 0
	for i := x; i < 10; i++ {
		res[j] = i
	}
	for i := 0; i < x; i++ {
		res[j] = i
	}
	return
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		var hc, dc, hm, dm, k, w, a int64
		fmt.Fscan(in, &hc, &dc, &hm, &dm, &k, &w, &a)

		var rc, rm, j int64
		isPossible := false
		for i := int64(0); i <= k; i++ {
			j = k - i
			rc = (hc + j*a) / dm
			rm = hm / (dc + i*w)
			if rc >= rm {
				isPossible = true
			}
		}

		if isPossible {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}

	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := readInt()
	m := readInt()
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		u := readInt() - 1
		v := readInt() - 1
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}
	vis := make([]bool, n)
	for i := 0; i < n; i++ {
		if !vis[i] {
			values := dfs(g, vis, i, nil)
			for _, u := range values {
				if len(g[u]) != len(values) - 1 {
					fmt.Println("NO")
					return
					break
				}
			}
		}
	}
	fmt.Println("YES")
}

func dfs(g [][]int, vis []bool, u int, values []int) []int {
	vis[u] = true
	values = append(values, u)
	for _, v := range g[u] {
		if !vis[v] {
			values = dfs(g, vis, v, values)
		}
	}
	return values
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := readInt()
	m := readInt()
	sizes := make([]int, n)
	set := NewDJSet(n)
	for i := 0; i < m; i++ {
		v := readInt() - 1
		u := readInt() - 1
		set.Union(v, u)
		sizes[u]++
		sizes[v]++
	}
	ans := true

	byroot := make([]int, n)
	for i := 0; i < n; i++ {
		root := set.Root(i)
		byroot[root] += sizes[i]
	}
	visit := make([]bool, n)
	for i := 0; i < n; i++ {
		root := set.Root(i)
		if !visit[root] {
			visit[root] = true
			size := int64(-set.Upper(root))
			if size > 0 {
				if size*(size-1) != int64(byroot[root]) {
					ans = false
					break
				}
			}
		}
	}
	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

type DJSet struct {
	upper []int
}

func NewDJSet(n int) *DJSet {
	s := DJSet{upper: make([]int, n)}
	for i := 0; i < n; i++ {
		s.upper[i] = -1
	}
	return &s
}

func (s *DJSet) Root(x int) int {
	if s.upper[x] < 0 {
		return x
	} else {
		s.upper[x] = s.Root(s.upper[x])
	}
	return s.upper[x]
}

func (s *DJSet) Union(x, y int) bool {
	x = s.Root(x)
	y = s.Root(y)
	if x != y {
		if s.upper[y] < s.upper[x] {
			x, y = y, x
		}
		s.upper[x] += s.upper[y]
		s.upper[y] = x
	}
	return x == y
}

func (s *DJSet) Equiv(x, y int) bool {
	return s.Root(x) == s.Root(y)
}

func (s *DJSet) Upper(y int) int {
	return s.upper[y]
}

func (s *DJSet) Count() int {
	ct := 0
	for _, u := range s.upper {
		if u < 0 {
			ct++
		}
	}
	return ct
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var y []int
var x []int

func solve() {
	n := readInt()
	m := readInt()
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		v := readInt() - 1
		u := readInt() - 1
		matrix[v] = append(matrix[v], u)
		matrix[u] = append(matrix[u], v)
	}
	visited := make([]bool, n)
	ans := true
	for i := 0; i < n; i++ {
		if !visited[i] {
			cur := make([]int, 0)
			res := int64(dfs(i, matrix, visited, &cur))
			size := int64(len(cur))
			if size*(size-1) != res {
				ans = false
				break
			}
		}
	}
	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func dfs(u int, matrix [][]int, visited []bool, cur *[]int) int {
	*cur = append(*cur, u)
	visited[u] = true
	res := 0
	for i := 0; i < len(matrix[u]); i++ {
		v := matrix[u][i]
		if !visited[v] {
			res += dfs(v, matrix, visited, cur)
		}
		res++
	}
	return res
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var edges int64
var size int64

func solve() {
	n := readInt()
	m := readInt()
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		v := readInt() - 1
		u := readInt() - 1
		matrix[v] = append(matrix[v], u)
		matrix[u] = append(matrix[u], v)
	}
	visited := make([]bool, n)
	ans := true
	for i := 0; i < n; i++ {
		if !visited[i] {
			edges = 0
			size = 0
			dfs(i, matrix, visited)
			if size*(size-1) != edges {
				ans = false
				break
			}
		}
	}
	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func dfs(u int, matrix [][]int, visited []bool) {
	visited[u] = true
	size++
	for _, v := range matrix[u] {
		if !visited[v] {
			dfs(v, matrix, visited)
		}
		edges++
	}
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var y []int
var x []int

func solve() {
	n := readInt()
	m := readInt()
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		v := readInt() - 1
		u := readInt() - 1
		matrix[v] = append(matrix[v], u)
		matrix[u] = append(matrix[u], v)
	}
	visited := make([]bool, n)
	for i := 0; i < n; i++ {
		if !visited[i] {
			cur := make([]int, 0)
			res := dfs(i, matrix, visited, &cur)
			size := len(cur)
			if size*(size-1) != res {
				fmt.Println("NO")
				return
			}
		}
	}
	fmt.Println("YES")
}

func dfs(u int, matrix [][]int, visited []bool, cur *[]int) int {
	*cur = append(*cur, u)
	visited[u] = true
	res := 0
	for i := 0; i < len(matrix[u]); i++ {
		v := matrix[u][i]
		if !visited[v] {
			res += dfs(v, matrix, visited, cur)
		}
		res++
	}
	return res
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var y []int
var x []int

func solve() {
	n := readInt()
	m := readInt()
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		v := readInt() - 1
		u := readInt() - 1
		matrix[v] = append(matrix[v], u)
		matrix[u] = append(matrix[u], v)
	}
	visited := make([]bool, n)
	ans := true
	for i := 0; i < n; i++ {
		if !visited[i] {
			cur := make([]int, 0)
			res := dfs(i, matrix, visited, &cur)
			size := len(cur)
			if size*(size-1) != res {
				ans = false
				break
			}
		}
	}
	if ans {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func dfs(u int, matrix [][]int, visited []bool, cur *[]int) int {
	*cur = append(*cur, u)
	visited[u] = true
	res := 0
	for i := 0; i < len(matrix[u]); i++ {
		v := matrix[u][i]
		if !visited[v] {
			res += dfs(v, matrix, visited, cur)
		}
		res++
	}
	return res
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}


package main

import "fmt"

func findGood(str string) string {
	bs := []byte(str)

	var ret []byte

	for _, c := range bs {
		if len(ret) % 2 == 0 || c != ret[len(ret) - 1] {
			ret = append(ret, c)
		}
	}

	l := len(ret)
	if l % 2 != 0 {
		ret = ret[: l / 2 * 2]
	}

	//for i := 0; i < len(bs); i++ {
	//	c := bs[i]
	//
	//	for j := 0; i+j < len(bs); j++ {
	//		if c != bs[i+j] {
	//			i += j
	//			ret = append(ret, c, bs[i])
	//			break
	//		}
	//	}
	//}

	return string(ret)
}

func main() {
	var n int
	var str string

	_, _ = fmt.Scanln(&n)
	_, _ = fmt.Scanln(&str)

	ret := findGood(str)

	fmt.Println(n - len(ret))
	fmt.Println(ret)
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

var DEBUG = true

func main() {
	defer Flush()

	N := readi()
	_ = N
	s := readb()

	var t []byte
	var i int
	for i < N-1 {
		j := i + 1
		for j < N && s[i] == s[j] {
			j++
		}
		if j == N {
			break
		}
		t = append(t, s[i], s[j])
		i = j + 1
	}
	println(N - len(t))
	if len(t) != 0 {
		println(string(t))
	}
}

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}


package main

import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)

    ScanInts := func(a... *int) {
        for i := 0; i < len(a); i++ {
            scanner.Scan()
            *(a[i]), _ = strconv.Atoi(scanner.Text())
        }
    }

    var n,m int
    ScanInts(&n,&m)
    ans, check, impossible := 0, make([]bool,m), false
    for i := 0; i < n; i++ {
        scanner.Scan()
        s := scanner.Text()
        G, S := 0, 0
        for j := 0; j < m; j++ {
            if s[j] == 'G' { G = j }
            if s[j] == 'S' { S = j}
        }
        if S < G {
            impossible = true
        } else {
            if !check[S-G] {
                check[S-G] = true
                ans++
            }
        }
    }
    if impossible {
        fmt.Println(-1)
    } else {
        fmt.Println(ans)
    }
}

package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	_ = m

	distances := make([]bool, 1000)

	for i:=0; i<n; i++ {
		line := next()

		a, b := strings.Index(line, "G"), strings.Index(line,"S")

		if a>b {
			println(-1)
			return
		}

		distances[b-a] = true
	}

	count := 0

	for i:=1; i<1000; i++ {
		if distances[i] {
			count++
		}
	}
	println(count)
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

package main
import (
	"fmt"
	"bufio"
	"os"
	//"strconv"
	//"sort"
)

func main() {
	var n,m,a,b int
	var b1 [1000]bool
	var s string
	input:= bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	//out := bufio.NewWriter(os.Stdout)
	o:=0
	flag:=false
	fmt.Scan(&n,&m)
	for i:=0;i<n;i++ {
		input.Scan()
		s = input.Text()
		for j:=0; j<m;j++ {
			if s[j]=='G' {
				a=j
			}
			if s[j]=='S' {
				b=j
			}
		}
		if a>b {
			fmt.Println("-1")
			flag=true
			break
		}
		b-=a
		if b1[b]==false {
			b1[b]=true
			o++
		}
	}
	if flag==false {
			fmt.Println(o)
	}
}

package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main() {
    scanner.Split(bufio.ScanWords)
    n := scanner.NextInt()
    m := scanner.NextInt()
    c := map[int]bool{}
    ans := 0
    for i := 0; ans >= 0 && i < n; i++ {
        s := scanner.Next()
        posG := -1
        posS := -1
        for j := 0; j < m; j++ {
            if s[j] == 'G' {
                posG = j
            } else if s[j] == 'S' {
                posS = j
            }
        }
        if posG < posS {
            if !c[posS-posG] {
                c[posS-posG] = true
                ans++
            }
        } else {
            ans = -1
        }
    }
    fmt.Println(ans)
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInt64() int64 {
    x, err := strconv.ParseInt(self.Next(), 10, 64)
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextDouble() float64 {
    x, err := strconv.ParseFloat(self.Next(), 64)
    if err != nil {
        panic(err)
    }
    return x
}

package main
import (
	"fmt"
	"bufio"
	"os"
	//"strconv"
	//"sort"
)

func main() {
	var n,m,a,b int
	var b1 [1000]bool
	var s string
	input:= bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	//out := bufio.NewWriter(os.Stdout)
	o:=0
	fmt.Scan(&n,&m)
	for i:=0;i<n;i++ {
		input.Scan()
		s = input.Text()
		for j:=0; j<m;j++ {
			if s[j]=='G' {
				a=j
			}
			if s[j]=='S' {
				b=j
			}
		}
		if a>b {
			fmt.Println("-1")
			break
		}
		b-=a
		if b1[b]==false {
			b1[b]=true
			o++
		}
	}
	fmt.Println(o)
}

package main

import "fmt"

func main() {
    var n,m int
    var s string
    fmt.Scan(&n,&m)
    ans, check, impossible := 0, make([]bool,m), false
    for i := 0; i < n; i++ {
        fmt.Scan(&s)
        for j := 0; j < m; j++ {
            if s[j] == 'G' {
                if !check[j] {
                    check[j] = true
                    ans++
                }
                break
            } else if s[j] == 'S' {
                impossible = true
                break
            }
        }
    }
    if impossible {
        fmt.Println(-1)
    } else {
        fmt.Println(ans)
    }
}

package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main() {
    scanner.Split(bufio.ScanWords)
    n := scanner.NextInt()
    m := scanner.NextInt()
    ans := 0
    for i := 0; ans >= 0 && i < n; i++ {
        s := scanner.Next()
        posG := -1
        posS := -1
        for j := 0; j < m; j++ {
            if s[j] == 'G' {
                posG = j
            } else if s[j] == 'S' {
                posS = j
            }
            if posG < posS {
                if posS-posG > ans {
                    ans = posS - posG
                }
            } else {
                ans = -1
            }
        }
    }
    fmt.Println(ans)
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInt64() int64 {
    x, err := strconv.ParseInt(self.Next(), 10, 64)
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextDouble() float64 {
    x, err := strconv.ParseFloat(self.Next(), 64)
    if err != nil {
        panic(err)
    }
    return x
}


package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  numBells, numBoxes := getI(), getI()
  bells := make([]int, numBells)
  for i := 0; i < numBells; i++ {
    bells[i] = getI()
  }
  result := 0

  pos := 2 * (numBells - numBoxes)
  if pos < 0 {
    pos = 0
  }
  left, right := 0, pos - 1
  for left < right {
    need := bells[left] + bells[right]
    if need > result {
      result = need
    }
    left++
    right--
  }
  for i := pos; i < numBells; i++ {
    need := bells[i]
    if need > result {
      result = need
    }
  }

  writer.WriteString(fmt.Sprintf("%d\n", result))
}

package main

import (
	"fmt"
	"os"
	"strings"
	"bufio"
	"sort"
	"strconv"
)

var n,k,s int
var e []int

func main() {

	input()

	sort.Sort(sort.IntSlice(e))
	a:=n-k

	smax:=0
	for i:=0; i<a; i++ {
		j:=2*a-i-1
		si:=e[i]+e[j]
		if si>smax { smax=si }
	}

	smax2:=e[n-1]
	if smax>smax2 {
		s=smax
	} else {
		s=smax2
	}

	output()
}

func get_int(s string) int {
	v,err:=strconv.Atoi(s)
	if err!=nil { fail() }
	return v
}

func get_int2(s string) (int,int) {
	pos:=strings.IndexByte(s,' ')
	if pos==-1 { fail() }
	v1:=get_int(s[:pos])
	v2:=get_int(s[pos+1:])
	return v1,v2
}

func input() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	n=get_int(scanner.Text())
	scanner.Scan()
	k=get_int(scanner.Text())

	e=make([]int,n)
	for i:=0; i<n; i++ {
		if !scanner.Scan() { fail() }
		e[i]=get_int(scanner.Text())
	}
}

func output() {
	fmt.Print(s)
}

const TRACE = 0

func assert(b bool) {
	if !b { panic("") }
}

func fail() {
	panic("")
}

func trace(v ...interface{}) {
	if TRACE == 1 {
		fmt.Fprint(os.Stderr,"[trace] ")
		fmt.Fprintln(os.Stderr,v...)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var s []int
var n, k int

func notFitin(x int) bool {
	cnt := 0
	for i, j := 0, n -1; i <= j; {
		if (i == j) {
			i++
			j--
		} else if s[i] + s[j] <= x {
			i++
			j--
		} else {
			j--
		}
		cnt++
	}
	return cnt > k
}

func main() {
	stdin := bufio.NewReader(os.Stdin)

	fmt.Fscanf(stdin, "%d%d\n", &n, &k)
	s = make([]int, n)

	l := 0
	for i := 0; i < n; i++ {
		fmt.Fscanf(stdin, "%d", &s[i])
		if s[i] > l {
			l = s[i]
		}
	}

	r := 2000000
	for l < r {
		mid := (l+r)/2
		if notFitin(mid) {
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Println(l)

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var s []int
var n, k int

func notFitin(x int) bool {
	rest := 0
	used := 0
	cnt := 0
	for i := 0; i < n; i ++ {
		if rest < s[i] || cnt == 2 {
			rest = x
			used++
			if used > k {
				return true
			}
			cnt = 0
		}
		rest -= s[i]

	}
	return false
}

func main() {
	stdin := bufio.NewReader(os.Stdin)

	fmt.Fscanf(stdin, "%d%d\n", &n, &k)
	s = make([]int, n)

	l := 0
	for i := 0; i < n; i++ {
		fmt.Fscanf(stdin, "%d", &s[i])
		if s[i] > l {
			l = s[i]
		}
	}

	r := 2000000
	for l < r {
		mid := (l+r)/2
		if notFitin(mid) {
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Println(l)

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var s []int
var n, k int

func notFitin(x int) bool {
	cnt := 0
	for i, j := 0, n -1; i <= j; {
		if (i == j) {
			i++
			j--
		} else if s[i] + s[j] <= x {
			i++
			j--
		} else {
			j--
		}
		cnt++
	}
	return cnt > k
}

func main() {
	stdin := bufio.NewReader(os.Stdin)

	fmt.Fscanf(stdin, "%d%d\n", &n, &k)
	s = make([]int, n)

	l := 0
	for i := 0; i < n; i++ {
		fmt.Fscanf(stdin, "%d", &s[i])
		if s[i] > l {
			l = s[i]
		}
	}

	r := 20
	for l < r {
		mid := (l+r)/2
		if notFitin(mid) {
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Println(l)

}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var s []int
var n, k int

func notFitin(x int) bool {
	rest := 0
	used := 0
	cnt := 0
	for i := 0; i < n; i ++ {
		if rest < s[i] || cnt == 2 {
			rest = x
			used++
			if used > k {
				return true
			}
			cnt = 0
		}
		rest -= s[i]
		cnt++

	}
	return false
}

func main() {
	stdin := bufio.NewReader(os.Stdin)

	fmt.Fscanf(stdin, "%d%d\n", &n, &k)
	s = make([]int, n)

	l := 0
	for i := 0; i < n; i++ {
		fmt.Fscanf(stdin, "%d", &s[i])
		if s[i] > l {
			l = s[i]
		}
	}

	r := 2000000
	for l < r {
		mid := (l+r)/2
		if notFitin(mid) {
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Println(l)

}