package main

import (
	"fmt"
    "os"
    "io/ioutil"
    //~ "time"
)

var stdin_bytes []byte

func read_int() int {
    if len(stdin_bytes) == 0 {
        stdin_bytes, _ = ioutil.ReadAll(os.Stdin)
    }
    for !('0' <= stdin_bytes[0] && stdin_bytes[0] <= '9') {
        stdin_bytes = stdin_bytes[1:]
    }
    x := 0
    for '0' <= stdin_bytes[0] && stdin_bytes[0] <= '9' {
        x = 10 * x + int(stdin_bytes[0] - '0')
        stdin_bytes = stdin_bytes[1:]
    }
    return x
}

type Range struct {
    start, end int
}

type Node struct {
    left_red_cost, right_blue_cost, cost int64
    left_range, right_range Range
    left_child, right_child, parent *Node
}

type Tree struct {
    levels uint
    colors []bool
    costs []int64
    nodes [][]Node
}

func compute_red_blue_costs(tree *Tree, node *Node) {
    node.left_red_cost = 0
    for i := node.left_range.start; i < node.left_range.end; i++ {
        if tree.colors[i] == true {
            node.left_red_cost += tree.costs[i]
        }
    }
    node.right_blue_cost = 0
    for i := node.right_range.start; i < node.right_range.end; i++ {
        if tree.colors[i] == false {
            node.right_blue_cost += tree.costs[i]
        }
    }
}

func update_cost(node *Node) {
    costs_left_red := node.left_red_cost + node.right_child.cost;
    costs_right_blue := node.right_blue_cost + node.left_child.cost;
    if costs_left_red < costs_right_blue {
        node.cost = costs_left_red;
    } else {
        node.cost = costs_right_blue;
    }
}

func build_tree(colors []bool, costs []int64) Tree {
    var tree Tree

    tree.levels = 1
    n := len(colors)
    for n > 1 {
        tree.levels++
        n >>= 1
    }
    if len(colors) > (1 << (tree.levels - 1)) {
        tree.levels += 1
    }

    tree.colors = make([]bool, 1 << (tree.levels - 1))
    copy(tree.colors, colors)
    tree.costs = make([]int64, 1 << (tree.levels - 1))
    copy(tree.costs, costs)

    num_nodes := len(tree.costs)
    for level := uint(0); level < tree.levels; level++ {
        tree.nodes = append(tree.nodes, make([]Node, num_nodes))
        num_nodes >>= 1
    }

    for level := uint(1); level < tree.levels; level++ {
        for i, _ := range tree.nodes[level] {
            node := &tree.nodes[level][i]
            left_child := &tree.nodes[level - 1][2 * i]
            right_child := &tree.nodes[level - 1][2 * i + 1]
            left_child.parent = node
            right_child.parent = node
            node.left_child = left_child
            node.right_child = right_child
            node.left_range = Range{i << level,
                    i << level + (1 << (level - 1))}
            node.right_range = Range{i << level + (1 << (level - 1)),
                    (i + 1) << level}
            compute_red_blue_costs(&tree, node)
            update_cost(node);
        }
    }

    return tree
}

func update_tree(tree *Tree, index int) {
    new_color := !tree.colors[index]
    tree.colors[index] = new_color
    for level := uint(1); level < tree.levels; level++ {
        i := index >> level
        //~ fmt.Println(level, index, i)
        node := &tree.nodes[level][i]
        if index < node.left_range.end {
            if new_color == false {
                node.left_red_cost -= tree.costs[index]
            } else {
                node.left_red_cost += tree.costs[index]
            }
        } else {
            if new_color == false {
                node.right_blue_cost += tree.costs[index]
            } else {
                node.right_blue_cost -= tree.costs[index]
            }
        }
        //~ fmt.Println("old cost:", node.cost)
        update_cost(node)
        //~ fmt.Println("new cost:", node.cost)
    }
}

func tree_cost(tree *Tree) int64 {
    return tree.nodes[tree.levels - 1][0].cost
}

func main() {
    n := read_int()
    perm := make([]int, n)
    for i := 0; i < n; i++ {
        perm[i] = read_int() - 1
    }
    colors := make([]bool, n)
    for i := 0; i < n; i++ {
        colors[i] = true
    }
    costs_raw := make([]int64, n)
    for i := 0; i < n; i++ {
        costs_raw[i] = int64(read_int())
    }
    costs := make([]int64, n)
    for i := 0; i < n; i++ {
        costs[perm[i]] = costs_raw[i]
    }

    //~ fmt.Println(perm, costs)

    //~ colors := []bool{false, true, false, true, false, true}
    //~ costs := []int{9, 1, 9, 9, 1, 9}

    tree := build_tree(colors, costs)
    //~ fmt.Println(tree)

    best_cost := int64(-1)
    for i := 0; i < n - 1; i++ {
        update_tree(&tree, perm[i])
        cost := tree_cost(&tree)
        if best_cost == -1 || cost < best_cost {
            best_cost = cost
        }
        //~ fmt.Println("idx:", perm[i], "->", tree.colors, "cost:", tree_cost(&tree))
    }

    fmt.Println(best_cost)
}

package main

import (
	"fmt"
    "os"
    "io/ioutil"
    //~ "time"
)

var stdin_bytes []byte

func read_int() int {
    if len(stdin_bytes) == 0 {
        stdin_bytes, _ = ioutil.ReadAll(os.Stdin)
    }
    for !('0' <= stdin_bytes[0] && stdin_bytes[0] <= '9') {
        stdin_bytes = stdin_bytes[1:]
    }
    x := 0
    for '0' <= stdin_bytes[0] && stdin_bytes[0] <= '9' {
        x = 10 * x + int(stdin_bytes[0] - '0')
        stdin_bytes = stdin_bytes[1:]
    }
    return x
}

type Node struct {
    left_red_cost, right_blue_cost, cost int64
}

type Tree struct {
    levels int
    colors []bool
    costs []int64
    nodes [][]Node
}

func node_left_child(tree *Tree, level int, i int) *Node {
    return &tree.nodes[level - 1][2 * i]
}

func node_right_child(tree *Tree, level int, i int) *Node {
    return &tree.nodes[level - 1][2 * i + 1]
}

func node_left_range(tree *Tree, level int, i int) (
start int, end int) {
    return i << uint(level),
           i << uint(level) + (1 << (uint(level) - 1))
}

func node_right_range(tree *Tree, level int, i int) (
start int, end int) {
    return i << uint(level) + (1 << (uint(level) - 1)),
           (i + 1) << uint(level)
}

func compute_red_blue_costs(tree *Tree, level int, i int) {
    node := &tree.nodes[level][i]
    node.left_red_cost = 0
    left_start, left_end := node_left_range(tree, level, i)
    for i := left_start; i < left_end; i++ {
        if tree.colors[i] == true {
            node.left_red_cost += tree.costs[i]
        }
    }
    node.right_blue_cost = 0
    right_start, right_end := node_right_range(tree, level, i)
    for i := right_start; i < right_end; i++ {
        if tree.colors[i] == false {
            node.right_blue_cost += tree.costs[i]
        }
    }
}

func update_cost(tree *Tree, level int, i int) {
    node := &tree.nodes[level][i]
    left_child := node_left_child(tree, level, i)
    right_child := node_right_child(tree, level, i)
    costs_left_red := node.left_red_cost + right_child.cost
    costs_right_blue := node.right_blue_cost + left_child.cost
    if costs_left_red < costs_right_blue {
        node.cost = costs_left_red;
    } else {
        node.cost = costs_right_blue;
    }
}

func build_tree(colors []bool, costs []int64) Tree {
    var tree Tree

    tree.levels = 1
    n := len(colors)
    for n > 1 {
        tree.levels++
        n >>= 1
    }
    if len(colors) > (1 << uint(tree.levels - 1)) {
        tree.levels += 1
    }

    tree.colors = make([]bool, 1 << uint(tree.levels - 1))
    copy(tree.colors, colors)
    tree.costs = make([]int64, 1 << uint(tree.levels - 1))
    copy(tree.costs, costs)

    num_nodes := len(tree.costs)
    for level := 0; level < tree.levels; level++ {
        tree.nodes = append(tree.nodes, make([]Node, num_nodes))
        num_nodes >>= 1
    }

    for level := 1; level < tree.levels; level++ {
        for i, _ := range tree.nodes[level] {
            compute_red_blue_costs(&tree, level, i)
            update_cost(&tree, level, i);
        }
    }

    return tree
}

func update_tree(tree *Tree, index int) {
    new_color := !tree.colors[index]
    tree.colors[index] = new_color
    for level := 1; level < tree.levels; level++ {
        i := index >> uint(level)
        //~ fmt.Println(level, index, i)
        node := &tree.nodes[level][i]
        _, left_end := node_left_range(tree, level, i)
        if index < left_end {
            if new_color == false {
                node.left_red_cost -= tree.costs[index]
            } else {
                node.left_red_cost += tree.costs[index]
            }
        } else {
            if new_color == false {
                node.right_blue_cost += tree.costs[index]
            } else {
                node.right_blue_cost -= tree.costs[index]
            }
        }
        //~ fmt.Println("old cost:", node.cost)
        update_cost(tree, level, i)
        //~ fmt.Println("new cost:", node.cost)
    }
}

func tree_cost(tree *Tree) int64 {
    return tree.nodes[tree.levels - 1][0].cost
}

func main() {
    n := read_int()
    perm := make([]int, n)
    for i := 0; i < n; i++ {
        perm[i] = read_int() - 1
    }
    colors := make([]bool, n)
    for i := 0; i < n; i++ {
        colors[i] = true
    }
    costs_raw := make([]int64, n)
    for i := 0; i < n; i++ {
        costs_raw[i] = int64(read_int())
    }
    costs := make([]int64, n)
    for i := 0; i < n; i++ {
        costs[perm[i]] = costs_raw[i]
    }

    //~ fmt.Println(perm, costs)

    //~ colors := []bool{false, true, false, true, false, true}
    //~ costs := []int{9, 1, 9, 9, 1, 9}

    tree := build_tree(colors, costs)
    //~ fmt.Println(tree)

    best_cost := int64(-1)
    for i := 0; i < n - 1; i++ {
        update_tree(&tree, perm[i])
        cost := tree_cost(&tree)
        if best_cost == -1 || cost < best_cost {
            best_cost = cost
        }
        //~ fmt.Println("idx:", perm[i], "->", tree.colors, "cost:", tree_cost(&tree))
    }

    fmt.Println(best_cost)
}

package main

import (
	"fmt"
    "os"
    "io/ioutil"
    //~ "time"
)

var stdin_bytes []byte

func read_int() int {
    if len(stdin_bytes) == 0 {
        stdin_bytes, _ = ioutil.ReadAll(os.Stdin)
    }
    for !('0' <= stdin_bytes[0] && stdin_bytes[0] <= '9') {
        stdin_bytes = stdin_bytes[1:]
    }
    x := 0
    for '0' <= stdin_bytes[0] && stdin_bytes[0] <= '9' {
        x = 10 * x + int(stdin_bytes[0] - '0')
        stdin_bytes = stdin_bytes[1:]
    }
    return x
}

type Range struct {
    start, end int
}

type Node struct {
    left_red_cost, right_blue_cost, cost int
    left_range, right_range Range
    left_child, right_child, parent *Node
}

type Tree struct {
    levels uint
    colors []bool
    costs []int
    nodes [][]Node
}

func compute_red_blue_costs(tree *Tree, node *Node) {
    node.left_red_cost = 0
    for i := node.left_range.start; i < node.left_range.end; i++ {
        if tree.colors[i] == true {
            node.left_red_cost += tree.costs[i]
        }
    }
    node.right_blue_cost = 0
    for i := node.right_range.start; i < node.right_range.end; i++ {
        if tree.colors[i] == false {
            node.right_blue_cost += tree.costs[i]
        }
    }
}

func update_cost(node *Node) {
    costs_left_red := node.left_red_cost + node.right_child.cost;
    costs_right_blue := node.right_blue_cost + node.left_child.cost;
    if costs_left_red < costs_right_blue {
        node.cost = costs_left_red;
    } else {
        node.cost = costs_right_blue;
    }
}

func build_tree(colors []bool, costs []int) Tree {
    var tree Tree

    tree.levels = 1
    n := len(colors)
    for n > 1 {
        tree.levels++
        n >>= 1
    }
    if len(colors) > (1 << (tree.levels - 1)) {
        tree.levels += 1
    }

    tree.colors = make([]bool, 1 << (tree.levels - 1))
    copy(tree.colors, colors)
    tree.costs = make([]int, 1 << (tree.levels - 1))
    copy(tree.costs, costs)

    num_nodes := len(tree.costs)
    for level := uint(0); level < tree.levels; level++ {
        tree.nodes = append(tree.nodes, make([]Node, num_nodes))
        num_nodes >>= 1
    }

    for level := uint(1); level < tree.levels; level++ {
        for i, _ := range tree.nodes[level] {
            node := &tree.nodes[level][i]
            left_child := &tree.nodes[level - 1][2 * i]
            right_child := &tree.nodes[level - 1][2 * i + 1]
            left_child.parent = node
            right_child.parent = node
            node.left_child = left_child
            node.right_child = right_child
            node.left_range = Range{i << level,
                    i << level + (1 << (level - 1))}
            node.right_range = Range{i << level + (1 << (level - 1)),
                    (i + 1) << level}
            compute_red_blue_costs(&tree, node)
            update_cost(node);
        }
    }

    return tree
}

func update_tree(tree *Tree, index int) {
    new_color := !tree.colors[index]
    tree.colors[index] = new_color
    for level := uint(1); level < tree.levels; level++ {
        i := index >> level
        //~ fmt.Println(level, index, i)
        node := &tree.nodes[level][i]
        if index < node.left_range.end {
            if new_color == false {
                node.left_red_cost -= tree.costs[index]
            } else {
                node.left_red_cost += tree.costs[index]
            }
        } else {
            if new_color == false {
                node.right_blue_cost += tree.costs[index]
            } else {
                node.right_blue_cost -= tree.costs[index]
            }
        }
        //~ fmt.Println("old cost:", node.cost)
        update_cost(node)
        //~ fmt.Println("new cost:", node.cost)
    }
}

func tree_cost(tree *Tree) int {
    return tree.nodes[tree.levels - 1][0].cost
}

func main() {
    n := read_int()
    perm := make([]int, n)
    for i := 0; i < n; i++ {
        perm[i] = read_int() - 1
    }
    colors := make([]bool, n)
    for i := 0; i < n; i++ {
        colors[i] = true
    }
    costs_raw := make([]int, n)
    for i := 0; i < n; i++ {
        costs_raw[i] = read_int()
    }
    costs := make([]int, n)
    for i := 0; i < n; i++ {
        costs[perm[i]] = costs_raw[i]
    }

    //~ fmt.Println(perm, costs)

    //~ colors := []bool{false, true, false, true, false, true}
    //~ costs := []int{9, 1, 9, 9, 1, 9}

    tree := build_tree(colors, costs)
    //~ fmt.Println(tree)

    best_cost := -1
    for i := 0; i < n - 1; i++ {
        update_tree(&tree, perm[i])
        cost := tree_cost(&tree)
        if best_cost == -1 || cost < best_cost {
            best_cost = cost
        }
        //~ fmt.Println("idx:", perm[i], "->", tree.colors, "cost:", tree_cost(&tree))
    }

    fmt.Println(best_cost)
}


package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI() // qty of cases (1st line)
	for cases != 0 {
		cases--
		attack, health, n := getI(), getI(), getI()
		monstersAtk := getInts(n)
		monstersHp := getInts(n)
		damage := int64(0)
		for i := int64(0); i < n; i++ {
			atks := int64(math.Ceil(float64(monstersHp[i]) / float64(attack)))
			damage += atks * monstersAtk[i]
		}
		res := "NO"
		for i := int64(0); i < n; i++ {
			if health-(damage-monstersAtk[i]) > 0 {
				res = "YES"
			}
		}
		out(res)
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
	"sort"
	"strconv"
	"strings"
)

var fields []string

func ScanString() string {
	field := ""

	for field == "" {
		field = fields[0]
		fields = fields[1:]
	}

	return field
}

func ScanInt() int {
	n, err := strconv.Atoi(ScanString())

	if err != nil {
		panic(err)
	}

	return n
}

func ScanInt64() int64 {
	n, err := strconv.ParseInt(ScanString(), 10, 64)

	if err != nil {
		panic(err)
	}

	return n
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, err := ioutil.ReadAll(bufio.NewReader(f))

	if err != nil {
		panic(err)
	}

	fields = strings.Fields(string(bytes))
}

type monster struct {
	a, b int64
}

type monsters []monster

func (m monsters) Len() int { return len(m) }

func (m monsters) Less(i, j int) bool { return m[i].a < m[j].a }

func (m monsters) Swap(i, j int) { m[i], m[j] = m[j], m[i] }

func main() {
	output := map[bool]string{false: "NO", true: "YES"}

	for t := ScanInt(); t > 0; t-- {
		A, B, n := ScanInt64(), ScanInt64(), ScanInt()
		ms := make(monsters, n)

		for i := range ms {
			ms[i].a = ScanInt64()
		}

		for i := range ms {
			ms[i].b = ScanInt64()
		}

		sort.Sort(ms)
		won := true

		for _, m := range ms {
			fightCnt := m.b / A

			if m.b%A > 0 {
				fightCnt++
			}

			B -= fightCnt * m.a

			if B+m.a <= 0 {
				won = false
			}
		}

		fmt.Println(output[won])
	}
}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
	"sort"
	"strings"
)

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func ScanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func ScanInt() int {
	return int(ScanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

type monster struct {
	a, b int64
}

type monsters []monster

func (m monsters) Len() int { return len(m) }

func (m monsters) Less(i, j int) bool { return m[i].a < m[j].a }

func (m monsters) Swap(i, j int) { m[i], m[j] = m[j], m[i] }

func main() {
	output := map[bool]string{false: "NO", true: "YES"}

	for t := ScanInt(); t > 0; t-- {
		A, B, n := ScanInt64(), ScanInt64(), ScanInt()
		ms := make(monsters, n)

		for i := range ms {
			ms[i].a = ScanInt64()
		}

		for i := range ms {
			ms[i].b = ScanInt64()
		}

		sort.Sort(ms)
		won := true

		for _, m := range ms {
			fightCnt := m.b / A

			if m.b%A > 0 {
				fightCnt++
			}

			B -= fightCnt * m.a

			if B+m.a <= 0 {
				won = false
			}
		}

		fmt.Println(output[won])
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

type Couple struct {
	a, b int
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	total := 1
	for t := 1; t <= T; t++ {
		var A, B, n int
		fmt.Fscan(reader, &A, &B, &n)
		c := make([]Couple, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &c[i].a)
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &c[i].b)
		}

		sort.Slice(c, func(i, j int) bool { return c[i].a < c[j].a })

		i := 0
		for i < n {
			times := c[i].b / A
			if c[i].b%A != 0 {
				times++
			}

			// j := 0
			// for j < times {
			// 	B = B - c[i].a
			// 	j++
			// 	if B <= 0 {
			// 		break
			// 	}
			// }
			// if j != times {
			// 	break
			// }

			can_fight := B / c[i].a
			if B%c[i].a != 0 {
				can_fight++
			}
			if can_fight < times {
				break
			} else {
				B = B - times*c[i].a
			}

			// if B-(times-1)*c[i].a > 0 {
			// 	B = B - c[i].a*times
			// } else {
			// 	break
			// }

			i++
			if B <= 0 {
				break
			}
		}
		if i == n {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

		total++
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var A, B int64
		var n int
		_, _ = fmt.Fscan(in, &A, &B, &n)

		a := make([]int64, n)
		b := make([]int64, n)
		for i := 0; i < n; i++ {
			_, _ = fmt.Fscan(in, &a[i])
		}
		for i := 0; i < n; i++ {
			_, _ = fmt.Fscan(in, &b[i])
		}

		var sum, max int64
		for i := 0; i < n; i++ {
			exp := a[i] * ((b[i] + A - 1) / A)

			sum += exp
			if a[i] > max {
				max = a[i]
			}
		}

		if B-sum+max > 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1480B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, atk, hp, n int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &atk, &hp, &n)
		mxI := 0
		a := make([]int64, n)
		for i := range a {
			Fscan(in, &a[i])
			if a[i] > a[mxI] {
				mxI = i
			}
		}
		b := make([]int64, n)
		for i := range b {
			Fscan(in, &b[i])
		}
		for i, v := range a {
			if i != mxI {
				hp -= ((b[i]-1)/atk + 1) * v
			}
		}
		hp -= (b[mxI] - 1) / atk * a[mxI]
		if hp > 0 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

func main() { CF1480B(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
    "sort"
)
var (
    input = bufio.NewReader(os.Stdin)
    output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assertion!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

type pair struct {a,b int64}

func solve() {
    var A, B, n int64
    fmt.Fscan(input, &A, &B, &n)
    a, b := make([]int64, n), make([]int64, n)
    pp := make([]pair, n)
    for i := int64(0); i < n; i++ {
        fmt.Fscan(input, &a[i])
    }
    damage := int64(0)
    for i := int64(0); i < n; i++ {
        fmt.Fscan(input, &b[i])
        pp[i].a = a[i]
        pp[i].b = b[i]
        damage += ((b[i] - 1) / A + 1) * a[i]
    }
    sort.Slice(pp, func(i, j int) bool { return pp[i].a > pp[j].a})
    if damage - pp[0].a <= B {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sints(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint(); t > 0; t-- {
		A := sint()
		B := sint()
		n := sint()
		a := sints(n)
		b := sints(n)
		printf("%s\n", sol(A, B, n, a, b))
	}
}

func sol(A, B, n int64, a, b []int64) string {
	dmg := int64(0)
	for i := int64(0); i < n; i++ {
		dmg += (b[i] + A - 1) / A * a[i]
	}
	for i := range a {
		if dmg-a[i] < B {
			return "YES"
		}
	}
	return "NO"
}

package main

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

func MIN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MAX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var A int
		var B int64
		var n int
		fmt.Fscan(input, &A)
		fmt.Fscan(input, &B)
		fmt.Fscan(input, &n)

		Attack := make([]int, n)
		health := make([]int, n)

		for i := 0; i < n; i++ {
			fmt.Fscan(input, &Attack[i])

		}
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &health[i])

		}
		var gidenjan int64
		for k := 0; k < n; k++ {
			if health[k]%A == 0 {
				gidenjan = gidenjan + int64(Attack[k])*int64((health[k]/A))
			} else {
				m := health[k] % A
				gidenjan = gidenjan + int64(Attack[k])*int64(((health[k]-m)/A)+1)
			}
		}

		galanjan := B - gidenjan
		if galanjan >= 0 {
			fmt.Println("YES")

		} else {
			sort.Slice(Attack, func(i, j int) bool {
				return Attack[i] > Attack[j]
			})
			if 0 < int64(Attack[0])+galanjan {
				fmt.Println("YES")

			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

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

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

	var t, a, b, n int64
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &a, &b, &n)

		var mxI int
		var ai, bi = make([]int64, n), make([]int64, n)

		for i := range ai {
			fmt.Fscan(in, &ai[i])
			if ai[i] > ai[mxI] {
				mxI = i
			}
		}

		for i := range bi {
			fmt.Fscan(in, &bi[i])
		}

		for i := range bi {
			if i == mxI {
				continue
			}

			bix := bi[i]
			cnt := ((bix - 1) / a) + 1
			b -= cnt * ai[i]
		}

		b -= ((bi[mxI] - 1) / a) * ai[mxI]

		if b > 0 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

	var t, a, b, n int64
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &a, &b, &n)

		var mxI int64
		var ai, bi = make([]int64, n), make([]int64, n)

		for i := int64(0); i < n; i++ {
			fmt.Fscan(in, &ai[i])
			if ai[i] > ai[mxI] {
				mxI = i
			}
		}

		for i := int64(0); i < n; i++ {
			fmt.Fscan(in, &bi[i])
		}

		for i := int64(0); i < n; i++ {
			if i == mxI {
				continue
			}

			bix := bi[i]
			cnt := ((bix - 1) / a) + 1
			b -= cnt * ai[i]
		}

		b -= ((bi[mxI] - 1) / a) * ai[mxI]

		if b > 0 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

type Couple struct {
	a, b int
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	total := 1
	for t := 1; t <= T; t++ {
		var A, B, n int
		fmt.Fscan(reader, &A, &B, &n)
		c := make([]Couple, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &c[i].a)
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &c[i].b)
		}
		if total == 3831 {
			fmt.Println(A, B, c)
		}
		sort.Slice(c, func(i, j int) bool { return c[i].a < c[j].a })

		i := 0
		for i < n {
			times := c[i].b / A
			if c[i].b%A != 0 {
				times++
			}

			// j := 0
			// for j < times {
			// 	B = B - c[i].a
			// 	j++
			// 	if B <= 0 {
			// 		break
			// 	}
			// }
			// if j != times {
			// 	break
			// }

			if B-(times-1)*c[i].a > 0 {
				B = B - c[i].a*times
			} else {
				break
			}

			i++
			if B <= 0 {
				break
			}
		}
		if i == n {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

		total++
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

type Couple struct {
	a, b int
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	total := 1
	for t := 1; t <= T; t++ {
		var A, B, n int
		fmt.Fscan(reader, &A, &B, &n)
		c := make([]Couple, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &c[i].a)
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &c[i].b)
		}
		sort.Slice(c, func(i, j int) bool { return c[i].a < c[j].a })

		i := 0
		for i < n {
			times := c[i].b / A
			if c[i].b%A != 0 {
				times++
			}

			if B-(times-1)*c[i].a > 0 {
				B = B - c[i].a*times
			} else {
				break
			}

			i++
			if B <= 0 {
				break
			}
		}
		if i == n {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

		total++
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	total := 1
	for t := 1; t <= T; t++ {
		var A, B, n int
		fmt.Fscan(reader, &A, &B, &n)
		a := make([]int, n)
		b := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &b[i])
		}
		if total == 20 {
			fmt.Println(A, B, a, b)
		}
		i := 0
		for i < n {
			times := b[i] / A
			if b[i]%A != 0 {
				times++
			}
			j := 0
			for j < times {
				B = B - a[i]
				j++
				if B <= 0 {
					break
				}
			}
			if j != times {
				break
			}
			i++
			if B <= 0 {
				break
			}
		}
		if i == n {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

		total++
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	total := 1
	for t := 1; t <= T; t++ {
		var A, B, n int
		fmt.Fscan(reader, &A, &B, &n)
		a := make([]int, n)
		b := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &b[i])
		}
		i := 0
		for i < n {
			times := b[i] / A
			if b[i]%A != 0 {
				times++
			}
			j := 0
			for j < times {
				B = B - a[i]
				j++
				if B <= 0 {
					break
				}
			}
			if j != times {
				break
			}
			i++
			if B <= 0 {
				break
			}
		}
		if i == n {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
		if total == 20 {
			fmt.Println(A, B, a, b)
		}
		total++
	}
}

// 00
package main

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

func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var A, B, n int
		fmt.Fscan(reader, &A, &B, &n)
		a := make([]int, n)
		b := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &b[i])
		}
		i := 0
		for i < n {
			times := b[i] / A
			if b[i]%A != 0 {
				times++
			}
			j := 0
			for j < times {
				B = B - a[i]
				j++
				if B <= 0 {
					break
				}
			}
			if j != times {
				break
			}
			i++
			if B <= 0 {
				break
			}
		}
		if i == n {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint() int {
	s := sstring()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func sints(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = sint()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint(); t > 0; t-- {
		A := sint()
		B := sint()
		n := sint()
		a := sints(n)
		b := sints(n)
		printf("%s\n", sol(A, B, n, a, b))
	}
}

type Monster struct {
	A int
	B int
}

func sol(A, B, n int, a, b []int) string {
	dmg := 0
	for i := 0; i < n; i++ {
		dmg += ceilDiv(b[i], A) * a[i]
	}
	for i := range a {
		if dmg-a[i] < B {
			return "YES"
		}
	}
	return "NO"
}

func ceilDiv(x, y int) int {
	return (x + y - 1) / y
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint() int {
	s := sstring()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func sints(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = sint()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint(); t > 0; t-- {
		A := sint()
		B := sint()
		n := sint()
		a := sints(n)
		b := sints(n)
		printf("%s\n", sol(A, B, n, a, b))
	}
}

type Monster struct {
	A int
	B int
}

func sol(A, B, n int, a, b []int) string {
	dmg := 0
	for i := 0; i < n; i++ {
		dmg += ceilDiv(b[i], A) * a[i]
	}
	for i := range a {
		if dmg - a[i] < B {
			return "YES"
		}
	}
	return "NO"
}

func ceilDiv(x, y int) int {
	if x%y == 0 {
		return x / y
	}
	return x/y + 1
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint() int {
	s := sstring()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func sints(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = sint()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint(); t > 0; t-- {
		A := sint()
		B := sint()
		n := sint()
		a := sints(n)
		b := sints(n)
		printf("%s\n", sol(A, B, n, a, b))
	}
}

type Monster struct {
	A int
	B int
}

func sol(A, B, n int, a, b []int) string {
	m := make([]Monster, n)
	for i := range m {
		m[i].A = a[i]
		m[i].B = b[i]
	}
	sort.Slice(m, func(il, ir int) bool {
		if m[il].A == m[ir].A {
			return m[il].B < m[ir].B
		}
		return m[il].A < m[ir].A
	})
	for i, mo := range m {
		na := ceilDiv(mo.B, A)
		B -= mo.A * na
		if B <= 0 {
			// it's ok for hero to die if last monster dies
			if i == n-1 && B+mo.A > 0 {
				return "YES"
			}
			return "NO"
		}
	}
	return "YES"
}

func ceilDiv(x, y int) int {
	if x%y == 0 {
		return x / y
	}
	return x/y + 1
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint() int {
	s := sstring()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func sints(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = sint()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint(); t > 0; t-- {
		A := sint()
		B := sint()
		n := sint()
		a := sints(n)
		b := sints(n)
		printf("%s\n", sol(A, B, n, a, b))
	}
}

type Monster struct {
	A int
	B int
}

func sol(A, B, n int, a, b []int) string {
	m := make([]Monster, n)
	for i := range m {
		m[i].A = a[i]
		m[i].B = b[i]
	}
	sort.Slice(m, func(il, ir int) bool {
		return m[il].A < m[ir].A
	})
	for i, mo := range m {
		na := ceilDiv(mo.B, A)
		B -= mo.A * na
		if B <= 0 {
			// it's ok for hero to die if last monster dies
			if i == n-1 && B+mo.A > 0 {
				return "YES"
			}
			return "NO"
		}
	}
	return "YES"
}

func ceilDiv(x, y int) int {
	if x%y == 0 {
		return x / y
	}
	return x/y + 1
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint() int {
	s := sstring()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func sints(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = sint()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint(); t > 0; t-- {
		A := sint()
		B := sint()
		n := sint()
		a := sints(n)
		b := sints(n)
		printf("%s\n", sol(A, B, n, a, b))
	}
}

type Monster struct {
	A int
	B int
}

func sol(A, B, n int, a, b []int) string {
	m := make([]Monster, n)
	for i := range m {
		m[i].A = a[i]
		m[i].B = b[i]
	}
	sort.Slice(m, func(il, ir int) bool {
		return m[il].A < m[ir].A
	})
	for i := 0; i < n; i++ {
		na := ceilDiv(b[i], A)
		B -= a[i] * na
		if B <= 0 {
			// it's ok for hero to die if last monster dies
			if i == n-1 && B+a[i] > 0 {
				return "YES"
			}
			return "NO"
		}
	}
	return "YES"
}

func ceilDiv(x, y int) int {
	if x%y == 0 {
		return x / y
	}
	return x/y + 1
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		A := sint64()
		B := sint64()
		n := sint64()
		a := sint64s(n)
		b := sint64s(n)
		printf("%s\n", sol(A, B, n, a, b))
	}
}

func sol(A, B, n int64, a, b []int64) string {
	for i := int64(0); i < n; i++ {
		na := ceilDiv(b[i], A)
		B -= a[i] * na
		if B <= 0 {
			// it's ok for hero to die if last monster dies
			if i == n-1 && B + a[i] > 0 {
				return "YES"
			}
			return "NO"
		}
	}
	return "YES"
}

func ceilDiv(x, y int64) int64 {
	if x%y == 0 {
		return x / y
	}
	return x/y + 1
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint() int {
	s := sstring()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func sints(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = sint()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint(); t > 0; t-- {
		A := sint()
		B := sint()
		n := sint()
		a := sints(n)
		b := sints(n)
		printf("%s\n", sol(A, B, n, a, b))
	}
}

func sol(A, B, n int, a, b []int) string {
	for i := 0; i < n; i++ {
		na := ceilDiv(b[i], A)
		B -= a[i] * na
		if B <= 0 {
			// it's ok for hero to die if last monster dies
			if i == n-1 && B + a[i] > 0 {
				return "YES"
			}
			return "NO"
		}
	}
	return "YES"
}

func ceilDiv(x, y int) int {
	if x%y == 0 {
		return x / y
	}
	return x/y + 1
}

package main

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

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

	var t, a, b, n int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &a, &b, &n)
		var ai, bi = make([]int, n), make([]int, n)

		var mxI int
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &ai[i])
			if ai[i] > ai[mxI] {
				mxI = i
			}
		}

		for i := 0; i < n; i++ {
			fmt.Fscan(in, &bi[i])
		}

		for i := 0; i < n; i++ {
			if i == mxI {
				continue
			}

			bix := bi[i]
			cnt := ((bix - 1) / a) + 1
			b -= cnt * ai[i]
		}

		b -= ((bi[mxI] - 1) / a) * ai[mxI]

		if b > 0 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

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

	var t, a, b, n int
	var ai, bi = make([]int, 1e6+7), make([]int, 1e6+7)

	for fmt.Fscan(in, &t); t > 0; t-- {
		var success = true
		fmt.Fscan(in, &a, &b, &n)

		for i := 0; i < n; i++ {
			fmt.Fscan(in, &ai[i])
		}

		for i := 0; i < n; i++ {
			fmt.Fscan(in, &bi[i])
		}

		for i := 0; i < n; i++ {
			bix := bi[i]
			cnt := bix / a
			if bix%a != 0 {
				cnt++
			}

			b -= cnt * ai[i]

			if b < 0 {
				if i == n-1 && b+ai[i] > 0 { // 最后一个并且最后一刀能打死
					success = true
				} else {
					success = false
				}
			}
		}

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

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI() // qty of cases (1st line)
	for cases != 0 {
		cases--
		attack, health, n := getI(), getI(), getI()
		monstersAtk := getInts(n)
		monstersHp := getInts(n)
		damage := int64(0)
		for i := int64(0); i < n; i++ {
			atks := int64(math.Ceil(float64(monstersHp[i]) / float64(attack)))
			damage += (atks - 1) * monstersAtk[i]
		}
		out(map[bool]string{true: "YES", false: "NO"}[health-damage > 0])
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI() // qty of cases (1st line)
	for cases != 0 {
		cases--
		attack, health, n := getI(), getI(), getI()
		monstersAtk := getInts(n)
		monstersHp := getInts(n)
		idxs := make([]int64, n)
		for i := int64(0); i < n; i++ {
			idxs[i] = i
		}

		sort.Slice(idxs, func(i, j int) bool {
			return (monstersHp[i]+monstersAtk[i])/2 < (monstersHp[j]+monstersAtk[j])/2
		})

		var count int64
		for count != n {
			cur := idxs[count]
			if health <= 0 {
				break
			}

			monstersHp[cur] -= attack
			health -= monstersAtk[cur]
			if monstersHp[cur] <= 0 {
				count++
			}
		}
		out(map[bool]string{true: "YES", false: "NO"}[count == n])
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI() // qty of cases (1st line)
	for cases != 0 {
		cases--
		attack, health, n := getI(), getI(), getI()
		monstersAtk := getInts(n)
		monstersHp := getInts(n)
		idxs := make([]int64, n)
		for i := int64(0); i < n; i++ {
			idxs[i] = i
		}

		sort.Slice(idxs, func(i, j int) bool {
			return (monstersHp[i]+monstersAtk[i])/2 < (monstersHp[j]+monstersAtk[i])/2
		})

		var count int64
		for count != n {
			if health <= 0 {
				break
			}

			cur := idxs[count]
			monstersHp[cur] -= attack
			health -= monstersAtk[cur]
			if monstersHp[cur] <= 0 {
				count++
			}
		}
		out(map[bool]string{true: "YES", false: "NO"}[count == n])
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI() // qty of cases (1st line)
	for cases != 0 {
		cases--
		attack, health, n := getI(), getI(), getI()
		monstersAtk := getInts(n)
		monstersHp := getInts(n)

		var count int64
		for count != n {
			if health <= 0 {
				break
			}

			monstersHp[count] -= attack
			health -= monstersAtk[count]
			if monstersHp[count] <= 0 {
				count++
			}
		}
		out(map[bool]string{true: "YES", false: "NO"}[count == n])
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
	"sort"
	"strings"
)

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func ScanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func ScanInt() int {
	return int(ScanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

type monster struct {
	a, b int
}

type monsters []monster

func (m monsters) Len() int { return len(m) }

func (m monsters) Less(i, j int) bool { return m[i].a < m[j].a }

func (m monsters) Swap(i, j int) { m[i], m[j] = m[j], m[i] }

func main() {
	output := map[bool]string{false: "NO", true: "YES"}

	for t := ScanInt(); t > 0; t-- {
		A, B, n := ScanInt(), ScanInt(), ScanInt()
		m := make(monsters, n)

		for i := range m {
			m[i].a = ScanInt()
		}

		for i := range m {
			m[i].b = ScanInt()
		}

		sort.Sort(m)
		won := true

		for i := 0; i < n; i++ {
			fightCnt := m[i].b / A

			if m[i].b%A > 0 {
				fightCnt++
			}

			B -= fightCnt * m[i].a

			if B+m[i].a <= 0 {
				won = false
			}
		}

		fmt.Println(output[won])
	}
}

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func ScanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func ScanInt() int {
	return int(ScanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	output := map[bool]string{false: "NO", true: "YES"}

	for t := ScanInt(); t > 0; t-- {
		A, B, n := ScanInt(), ScanInt(), ScanInt()
		a, b := make([]int, n), make([]int, n)
		won := true

		for i := range a {
			a[i] = ScanInt()
		}

		for i := range b {
			b[i] = ScanInt()
		}

		for i := 0; i < n; i++ {
			fightCnt := b[i] / A

			if b[i]%A > 0 {
				fightCnt++
			}

			B -= fightCnt * a[i]

			if B+a[i] <= 0 {
				won = false
			}
		}

		fmt.Println(output[won])
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1480B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, atk, hp, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &atk, &hp, &n)
		mxI := 0
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
			if a[i] > a[mxI] {
				mxI = i
			}
		}
		b := make([]int, n)
		for i := range b {
			Fscan(in, &b[i])
		}
		for i, v := range a {
			if i != mxI {
				hp -= ((b[i]-1)/atk + 1) * v
			}
		}
		hp -= (b[mxI] - 1) / atk * a[mxI]
		if hp > 0 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

func main() { CF1480B(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
    "sort"
)
var (
    input = bufio.NewReader(os.Stdin)
    output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assertion!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

type pair struct {a,b int64}

func solve() {
    var A, B, n int64
    fmt.Fscan(input, &A, &B, &n)
    a, b := make([]int64, n), make([]int64, n)
    pp := make([]pair, n)
    for i := int64(0); i < n; i++ {
        fmt.Fscan(input, &a[i])
    }
    damage := int64(0)
    for i := int64(0); i < n; i++ {
        fmt.Fscan(input, &b[i])
        pp[i].a = a[i]
        pp[i].b = b[i]
        damage += ((b[i] - 1) / A + 1) * a[i]
    }
    sort.Slice(pp, func(i, j int) bool { return ((pp[i].b - 1) / A + 1) * pp[i].a > ((pp[j].b - 1) / A + 1) * pp[j].a})
    if damage - pp[0].a < B {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

package main

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

func MIN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MAX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var A int
		var B int64
		var n int
		fmt.Fscan(input, &A)
		fmt.Fscan(input, &B)
		fmt.Fscan(input, &n)

		Attack := make([]int, n)
		health := make([]int, n)

		for i := 0; i < n; i++ {
			fmt.Fscan(input, &Attack[i])

		}
		for i := 0; i < n; i++ {
			fmt.Fscan(input, &health[i])

		}
		var gidenjan int64
		for k := 0; k < n; k++ {
			if health[k]%A == 0 {
				gidenjan = gidenjan + int64(Attack[k]*(health[k]/A))
			} else {
				gidenjan = gidenjan + int64(Attack[k]*(health[k]/A)) + int64(Attack[k])
			}
		}

		galanjan := B - gidenjan
		if galanjan >= 0 {
			fmt.Println("YES")

		} else {
			sort.Ints(Attack)
			if 0 < int64(Attack[n-1])+galanjan {
				fmt.Println("YES")

			} else {
				fmt.Println("NO")
			}
		}

	}
}


package main

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

func Solver(reader io.Reader, writer io.Writer) {
	var t int
	fmt.Fscanln(reader, &t)

	for ; t > 0; t-- {
		var n, k, r, c int
		fmt.Fscanln(reader, &n, &k, &r, &c)

		table := make([][]int, n)
		for i := range table {
			table[i] = make([]int, n)
		}

		for i := range table {
			for j := range table[i] {
				table[i][j] = '.'
			}

		}

		offset := (c - r + k*(r-1)) % k
		for i := 0; i < n; i++ {
			for j := 0; j < n; {
				table[i][j+offset] = 'X'
				j += k
			}
			offset = (offset + 1) % k
		}

		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				fmt.Fprintf(writer, "%c", table[i][j])
			}
			fmt.Fprintln(writer)
		}
	}
}

func main() {

	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)

	Solver(r, w)
	w.Flush()
}

package main

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

func Solver(reader io.Reader, writer io.Writer) {
	var t int
	fmt.Fscanln(reader, &t)

	for ; t > 0; t-- {
		var n, k, r, c int
		fmt.Fscanln(reader, &n, &k, &r, &c)

		table := make([]int, n*n)

		for i := range table {
			table[i] = '.'
		}

		v := (r-1)*n + c - 1
		table[v] = 'X'
		offset := ((v % k) - (r - 1) + k*(r-1)) % k

		for i := 0; i < n; i++ {
			for j := 0; j < n; {
				table[i*n+j+offset] = 'X'
				j += k
			}
			offset = (offset + 1) % k
		}

		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				fmt.Fprintf(writer, "%c", table[i*n+j])
			}
			fmt.Fprintln(writer)
		}
	}
}

func main() {

	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)

	Solver(r, w)
	w.Flush()
}

package main

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

func abs(n int) int {
	if n < 0 {
		return n * -1
	}
	return n
}

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 n, k, r, c int
		fmt.Fscan(in, &n, &k, &r, &c)

		z := (r + c) % k
		for i := 1; i <= n; i++ {
			for j := 1; j <= n; j++ {
				if (i+j)%k == z {
					fmt.Fprint(out, "X")
				} else {
					fmt.Fprint(out, ".")
				}
			}
			fmt.Fprintln(out)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var T int64
	fmt.Scanf("%d\n", &T)
	for c := int64(0); c < T; c++ {
		var n, k, r, c int
		fmt.Scanf("%d%d%d%d\n", &n, &k, &r, &c)
		for i := 1; i <= n; i++ {
			for j := 1; j <= n; j++ {
				if (i+j)%k == (r+c)%k {
					fmt.Print("X")
				} else {
					fmt.Print(".")
				}
			}
			fmt.Println()
		}
	}
}

package main

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

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

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

func Solve(reader *bufio.Reader) {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i_ := 0; i_ < t; i_++ {
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		r, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		c, _ := strconv.Atoi(scanner.Text())
		r--
		c--

		arr := make([][]string, n)
		for i := 0; i < n; i++ {
			arr[i] = make([]string, n)
			for j := 0; j < n; j++ {
				arr[i][j] = "."
			}
		}
		arr[r][c] = "X"
		m := n / k
		for j := 0; j < m; j++ {
			for i := 1; i <= n; i++ {
				arr[((r+j*k)+i)%n][(c-i+n)%n] = "X"
			}
		}

		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				wr.WriteString(arr[i][j])
			}
			wr.WriteString("\n")
		}
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	Solve(reader)
}

package main

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

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

func solve() {
	var k, n, r, c int
	fmt.Fscan(in, &n, &k, &r, &c)
	r--
	c--

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if (i-r+n)%k == (j-c+n)%k {
				fmt.Fprint(out, "X")
			} else {
				fmt.Fprint(out, ".")
			}
		}
		fmt.Fprintln(out)
	}
}

func main() {
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		solve()
	}
	out.Flush()
}

package main

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

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

func qwq() {
	var n, k, r, c int
	fmt.Fscan(in, &n, &k, &r, &c)
	a := make([][]byte, n)
	for i := range a {
		a[i] = make([]byte, n)
	}
	for i := range a {
		for j := range a[i] {
			a[i][j] = '.'
		}
	}
	p := c - 1
	for i := r - 1; i < n; i++ {
		for j := p; a[i][j] == '.'; j = (j + k) % n {
			a[i][j] = 'X'
		}
		p = (p - 1 + k) % k
	}
	p = c % k
	for i := r - 2; i >= 0; i-- {
		for j := p; a[i][j] == '.'; j = (j + k) % n {
			a[i][j] = 'X'
		}
		p = (p + 1 + k) % k
	}
	for i := 0; i < n; i++ {
		fmt.Fprintln(out, string(a[i]))
	}
}

func main() {
	defer out.Flush()
	q := 1
	fmt.Fscan(in, &q)
	for ; q > 0; q-- {
		qwq()
	}
}

package main

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

type float = float32
type double = float64
type long = int64
type ulong = uint64

type comparable interface {
	int | int8 | int16 | int32 | int64 |
		uint | uint8 | uint16 | uint32 | uint64 |
		float32 | float64
}

type pair[T comparable] struct {
	First  T
	Second T
}

func Max[T comparable](x, y T) T {
	return T(math.Max(float64(x), float64(y)))
}

func Min[T comparable](x, y T) T {
	return T(math.Min(float64(x), float64(y)))
}

var in = bufio.NewReader(os.Stdin)

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}
func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

func read[T comparable](reader func(...string) T) []T {
	strs := readStrings()
	arr := make([]T, len(strs))
	for i, val := range strs {
		arr[i] = reader(val)
	}
	return arr
}

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLn(arg ...interface{})               { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

func unpack[T comparable](arr []T, vars ...*T) {
	for i, vari := range vars {
		*vari = arr[i]
	}
}

func init1D[T comparable](n int, def T) []T {
	arr := make([]T, n)
	for i := 0; i < n; i++ {
		arr[i] = def
	}
	return arr
}

func init2D[T comparable](n, m int, def T) [][]T {
	arr := make([][]T, n)
	for i := 0; i < n; i++ {
		arr[i] = make([]T, m)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			arr[i][j] = def
		}
	}
	return arr
}

func solve() {
	var n, k, r, c int
	unpack(read(readInt), &n, &k, &r, &c)

	r, c = r-1, c-1

	matrix := init2D(k, k, '.')
	for i := 0; i < k; i++ {
		matrix[(r+i)%k][(c+i)%k] = 'X'
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j += k {
			write(string(matrix[i%k]))
		}
		writeLn()
	}
}
func main() {
	tc := read(readInt)[0]
	for ; tc > 0; tc -= 1 {
		solve()
	}
}

package main

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

type float = float32
type double = float64
type long = int64
type ulong = uint64

type comparable interface {
	int | int8 | int16 | int32 | int64 |
		uint | uint8 | uint16 | uint32 | uint64 |
		float32 | float64
}

type pair[T comparable] struct {
	First  T
	Second T
}

func Max[T comparable](x, y T) T {
	return T(math.Max(float64(x), float64(y)))
}

func Min[T comparable](x, y T) T {
	return T(math.Min(float64(x), float64(y)))
}

var in = bufio.NewReader(os.Stdin)

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}
func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

func read[T comparable](reader func(...string) T) []T {
	strs := readStrings()
	arr := make([]T, len(strs))
	for i, val := range strs {
		arr[i] = reader(val)
	}
	return arr
}

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLn(arg ...interface{})               { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

func unpack[T comparable](arr []T, vars ...*T) {
	for i, vari := range vars {
		*vari = arr[i]
	}
}

func init1D[T comparable](n int, def T) []T {
	arr := make([]T, n)
	for i := 0; i < n; i++ {
		arr[i] = def
	}
	return arr
}

func init2D[T comparable](n, m int, def T) [][]T {
	arr := make([][]T, n)
	for i := 0; i < n; i++ {
		arr[i] = make([]T, m)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			arr[i][j] = def
		}
	}
	return arr
}

func solve() {
	var n, k, r, c int
	unpack(read(readInt), &n, &k, &r, &c)

	r, c = r-1, c-1

	matrix := init2D(n, n, '.')
	for i := 0; i < k; i++ {
		matrix[(r+i)%k][(c+i)%k] = 'X'
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			write(string(matrix[i%k][j%k]))
		}
		writeLn()
	}
}
func main() {
	tc := read(readInt)[0]
	for ; tc > 0; tc -= 1 {
		solve()
	}
}

package main

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

type float = float32
type double = float64
type long = int64
type ulong = uint64

type comparable interface {
	int | int8 | int16 | int32 | int64 |
		uint | uint8 | uint16 | uint32 | uint64 |
		float32 | float64
}

type pair[T comparable] struct {
	First  T
	Second T
}

func Max[T comparable](x, y T) T {
	return T(math.Max(float64(x), float64(y)))
}

func Min[T comparable](x, y T) T {
	return T(math.Min(float64(x), float64(y)))
}

var in = bufio.NewReader(os.Stdin)

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}
func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

func read[T comparable](reader func(...string) T) []T {
	strs := readStrings()
	arr := make([]T, len(strs))
	for i, val := range strs {
		arr[i] = reader(val)
	}
	return arr
}

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLn(arg ...interface{})               { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

func unpack[T comparable](arr []T, vars ...*T) {
	for i, vari := range vars {
		*vari = arr[i]
	}
}

func solve() {
	var n, k, r, c int
	unpack(read(readInt), &n, &k, &r, &c)

	r, c = r-1, c-1

	matrix := make([][]rune, k)
	for i := 0; i < k; i++ {
		matrix[i] = make([]rune, k)
	}
	for i := 0; i < k; i++ {
		for j := 0; j < k; j++ {
			matrix[i][j] = '.'
		}
	}

	for i := 0; i < k; i++ {
		matrix[(r+i)%k][(c+i)%k] = 'X'
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			write(string(matrix[i%k][j%k]))
		}
		writeLn()
	}
}
func main() {
	tc := read(readInt)[0]
	for ; tc > 0; tc -= 1 {
		solve()
	}
}

package main

import "fmt"

func main() {
	var t, i1 int
	_, _ = fmt.Scanf("%d\n", &t)
	for i1 = 0; i1 < t; i1++ {
		var n, k, r, c int
		_, _ = fmt.Scanf("%d %d %d %d\n", &n, &k, &r, &c)
		var i2, d int
		s := ((r-1)*n + c + r - 2) % k
		for i2 = 0; i2 < n*n; i2++ {

			if d%k == s {
				fmt.Print("X")
			} else {
				fmt.Print(".")
			}
			d++
			if d == n {
				fmt.Println()
				s--
				if s == -1 {
					s = k - 1
				}
				d = 0
			}
		}
	}
}

package main

import "fmt"

func main() {
	var t, i1 int
	_, _ = fmt.Scanf("%d\n", &t)
	for i1 = 0; i1 < t; i1++ {
		var n, k, r, c int
		_, _ = fmt.Scanf("%d %d %d %d\n", &n, &k, &r, &c)
		var i2, d int
		s := ((r-1)*n + c + r - 2) % k
		fmt.Println(s)
		for i2 = 0; i2 < n*n; i2++ {

			if d%k == s {
				fmt.Print("X")
			} else {
				fmt.Print(".")
			}
			d++
			if d == n {
				fmt.Println()
				s--
				if s == -1 {
					s = k - 1
				}
				d = 0
			}
		}
	}
}

package main

import "fmt"

func main() {
	var t, i1 int
	_, _ = fmt.Scanf("%d\n", &t)
	for i1 = 0; i1 < t; i1++ {
		var n, k, r, c int
		_, _ = fmt.Scanf("%d %d %d %d\n", &n, &k, &r, &c)
		var i2, d int
		s := ((r-1)*n + c + r - 2) % k
		fmt.Println(s)
		for i2 = 0; i2 < n*n; i2++ {

			if d%k == s {
				fmt.Print("X")
			} else {
				fmt.Print(".")
			}
			d++
			if d == n {
				fmt.Println()
				s--
				if s == -1 {
					s = k - 1
				}
				d = 0
			}
		}
		fmt.Println()
	}
}

package main

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

func abs(n int) int {
	if n < 0 {
		return n * -1
	}
	return n
}

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 n, k, r, c int
		fmt.Fscan(in, &n, &k, &r, &c)

		mm := make([][]int, n)
		for i := 0; i < n; i++ {
			m := make([]int, n)
			// fmt.Println(i, ((abs(i-r) + c - 1) % k))
			j := ((abs(i-r) + c + 1) % k)
			if i > r {
				j = ((abs(i-r) + c - 1) % k)
			}
			for ; j < n; j += k {
				m[j] = 1
			}
			mm[i] = m
		}

		for _, row := range mm {
			for _, v := range row {
				if v == 1 {
					fmt.Fprint(out, "X")
				} else {
					fmt.Fprint(out, ".")
				}
			}
			fmt.Fprintln(out)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var T int64
	fmt.Scanf("%d\n", &T)
	for c := int64(0); c < T; c++ {
		var n, k, r, c int
		fmt.Scanf("%d%d%d%d\n", &n, &k, &r, &c)
		for i := 1; i <= n; i++ {
			for j := 1; j <= n; j++ {
				if (i+j)%k == (r+c)%k {
					print("X")
				} else {
					print(".")
				}
			}
			println()
		}
	}
}

package main

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

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

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

func Solve(reader *bufio.Reader) {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i_ := 0; i_ < t; i_++ {
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		wr.WriteString(strconv.Itoa(n+(n/2)*2+(n/3)*2) + "\n")
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	Solve(reader)
}


package main

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

const (
	MAX int = 1002
	H   int = 0
	V   int = 1
)

var (
	cur_max int = 0
	N       int
	M       int
	i       int
	a       [MAX][MAX]int
	c1, c2  [MAX][MAX]int // [0] for --> [1] for |
	c3, c4  [MAX][MAX]int
)

func maX(a int, b int) int {
	var ret int
	ret = a
	if a < b {
		ret = b
	}
	return ret
}

func print_c() {
	fmt.Printf("c1 : [H V]\n")
	for i = 1; i <= N; i++ {
		for j := 1; j <= M; j++ {
			fmt.Printf("%d ", c1[i][j])
		}
		fmt.Printf("\n")
	}

	fmt.Printf("c3 : [H V]\n")
	for i = 1; i <= N; i++ {
		for j := 1; j <= M; j++ {
			fmt.Printf("%d ", c3[i][j])
		}
		fmt.Printf("\n")
	}

	fmt.Printf("c2 : [H V]\n")
	for i = 1; i <= N; i++ {
		for j := 1; j <= M; j++ {
			fmt.Printf("%d ", c2[i][j])
		}
		fmt.Printf("\n")
	}

	fmt.Printf("c4 : [H V]\n")
	for i = 1; i <= N; i++ {
		for j := 1; j <= M; j++ {
			fmt.Printf("%d ", c4[i][j])
		}
		fmt.Printf("\n")
	}

}

func precomp() {
	// c1 lahua
	for i = 1; i <= N; i++ {
		for j := 1; j <= M; j++ {
			c1[i][j] = maX(c1[i-1][j]+a[i][j], c1[i][j-1]+a[i][j])
		}
	}
	// c3 lahua
	for i = N; i >= 1; i-- {
		for j := M; j >= 1; j-- {
			c3[i][j] = maX(c3[i+1][j]+a[i][j], c3[i][j+1]+a[i][j])
		}
	}

	// c2 lahuania
	for i = N; i >= 1; i-- {
		for j := 1; j <= M; j++ {
			c2[i][j] = maX(c2[i+1][j]+a[i][j], c2[i][j-1]+a[i][j])
		}
	}

	// c4 lahuania
	for i = 1; i <= N; i++ {
		for j := M; j >= 1; j-- {
			c4[i][j] = maX(c4[i-1][j]+a[i][j], c4[i][j+1]+a[i][j])
		}
	}

}

func solve() {
	for i = 2; i < N; i++ {
		for j := 2; j < M; j++ {
			var v1 int = c1[i][j-1] + c3[i][j+1] + c2[i+1][j] + c4[i-1][j]
			var v2 int = c1[i-1][j] + c3[i+1][j] + c2[i][j-1] + c4[i][j+1]
			if maX(v1, v2) > cur_max {
				cur_max = maX(v1, v2)
			}
		}
	}
	fmt.Printf("%d\n", cur_max)
}

func main() {
	input := bufio.NewReader(os.Stdin)
	// 1. read input
	fmt.Fscanf(input, "%d %d\n", &N, &M)
	for i = 1; i <= N; i++ {
		for j := 1; j <= M; j++ {
			fmt.Fscanf(input, "%d ", &a[i][j])
		}
	}

	precomp()
	//print_c()

	// 2. solve
	solve()

	return
}


package main

import "fmt"

func main(){
	var n int
	var arr []int64
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		var num int64
		fmt.Scanf("%d", &num)
		arr = append(arr, num)
	}

	for i := 0; i < n; i++ {
		if(judge(arr[i])){
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge(num int64) bool {
	if num < 14 {
		return false
	}
	i := num % 14
	if i <= 6 && i >= 1 {
		return true
	}
	return false
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		q := int64(0)
		fmt.Fscanf(in, "%d", &q)
		if q < 15 {
			fmt.Fprintf(out, "NO\n")
			continue
		}
		if q%14 >= 1 && q%14 <= 6 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	fmt.Fscanf(in, "\n")
	return
}

// first index in b >= a
func find(a int, b []int) int {
	n := len(b)
	if n == 0 {
		return -1
	}
	if b[n-1] < a {
		return -1
	}
	l := 0
	r := n - 1
	for l < r {
		mid := (l + r) / 2
		if b[mid] >= a {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

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

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

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		x := int64(0)
		fmt.Fscanf(in, "%d", &x)

		r := x % 14
		if r >= 1 && r <= 6 && x > 14 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]big.Int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		var bigNumber big.Int
		bigNumber.SetString(numberString, 10)
		numberSlice = append(numberSlice, bigNumber)
	}

	for _, number := range numberSlice {
		if number.Cmp(big.NewInt(7))<0 {
			fmt.Print("NO\n")
			continue
		}
		var modRes big.Int
		modRes.Mod(&number, big.NewInt(14))
		if modRes.Cmp(big.NewInt(0)) == 0 {
			fmt.Print("NO\n")
			continue
		}
		cmpRes := modRes.Cmp(big.NewInt(7))
		if cmpRes < 0 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

import (
	"fmt"
	"strconv"
)

func div7Val(num string) int {
	val := 0

	for _, ch := range num {
		val = (val*3 + int(ch-'0')) % 7
	}

	return val
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		yes := false
		var num string
		fmt.Scanf("%s", &num)
		if len(num) <= 2 {
			num2, _ := strconv.Atoi(num)
			if num2 <= 14 {
				fmt.Println("NO")
				continue
			}
		}
		val := div7Val(num)
		for j := 1; j <= 6; j++ {
			if (val-j)%7 == 0 && int(num[len(num)-1]-'0')%2 == j%2 {
				yes = true
				break
			}
		}
		if yes {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1266B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t, n int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		n, k := n%14, n/14
		if k > 0 && 1 <= n && n <= 6 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

func main() { CF1266B(os.Stdin, os.Stdout) }

package main

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

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]big.Int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, *big.NewInt(int64(number)))
	}

	for _, number := range numberSlice {
		if number.Cmp(big.NewInt(7))<0 {
			fmt.Print("NO\n")
			continue
		}
		var modRes big.Int
		modRes.Mod(&number, big.NewInt(14))
		if modRes.Cmp(big.NewInt(0)) == 0 {
			fmt.Print("NO\n")
			continue
		}
		cmpRes := modRes.Cmp(big.NewInt(7))
		if cmpRes < 0 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

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

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]big.Int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, *big.NewInt(int64(number)))
	}

	for _, number := range numberSlice {
		if number.Cmp(big.NewInt(15))<0 {
			fmt.Print("NO\n")
			continue
		}
		var modRes big.Int
		modRes.Mod(&number, big.NewInt(14))
		cmpRes := modRes.Cmp(big.NewInt(7))
		if cmpRes < 0 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

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

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, number)
	}

	for _, number := range numberSlice {
		if number < 7 {
			fmt.Print("NO\n")
			continue
		}
		if number%14 > 0 && number%14 < 7 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var number int
		_, _ = fmt.Scanf("%d\n", &number)
		if number%14 > 0 && number%14 < 7 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

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

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]big.Int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, *big.NewInt(int64(number)))
	}

	for _, number := range numberSlice {
		if number.Cmp(big.NewInt(7))<0 {
			fmt.Print("NO\n")
			continue
		}
		var modRes big.Int
		modRes.Mod(&number, big.NewInt(14))
		cmpRes := modRes.Cmp(big.NewInt(7))
		if cmpRes < 0 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

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

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')
	fmt.Print(inputString)

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, number)
	}

	for _, number := range numberSlice {
		if number%14 > 0 && number%14 < 7 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

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

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, number)
	}

	for _, number := range numberSlice {
		if number%14 > 0 && number%14 < 7 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

import "fmt"

func div7Val(num string) int {
	val := 0

	for _, ch := range num {
		val = (val*3 + int(ch-'0')) % 7
	}

	return val
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		yes := false
		var num string
		fmt.Scanf("%s", &num)
		val := div7Val(num)
		for j := 1; j <= 6; j++ {
			if (val-j)%7 == 0 && int(num[len(num)-1]-'0')%2 == j%2 {
				yes = true
				break
			}
		}
		if yes {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func div7Val(num string) int {
	val := 0

	for _, ch := range num {
		val = (val*3 + int(ch-'0')) % 7
	}

	return val
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		yes := false
		var num string
		fmt.Scanf("%s\n", &num)
		val := div7Val(num)
		for j := 1; j <= 6; j++ {
			if (val-j)%7 == 0 && int(num[len(num)-1]-'0')%2 == j%2 {
				yes = true
				break
			}
		}
		if yes {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1266B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var t, n int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		n %= 14
		if 1 <= n && n <= 6 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

func main() { CF1266B(os.Stdin, os.Stdout) }

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		q := int64(0)
		fmt.Fscanf(in, "%d", &q)
		if q%14 >= 1 && q%14 <= 6 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

// first index in b >= a
func find(a int, b []int) int {
	n := len(b)
	if n == 0 {
		return -1
	}
	if b[n-1] < a {
		return -1
	}
	l := 0
	r := n - 1
	for l < r {
		mid := (l + r) / 2
		if b[mid] >= a {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		q := int64(0)
		fmt.Fscanf(in, "%d", &q)
		if q%14 >= 1 && q%14 <= 6 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	fmt.Fscanf(in, "\n")
	return
}

// first index in b >= a
func find(a int, b []int) int {
	n := len(b)
	if n == 0 {
		return -1
	}
	if b[n-1] < a {
		return -1
	}
	l := 0
	r := n - 1
	for l < r {
		mid := (l + r) / 2
		if b[mid] >= a {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		q := int64(0)
		fmt.Fscanf(in, "%d\n", &q)
		if q%14 >= 1 && q%14 <= 6 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

// first index in b >= a
func find(a int, b []int) int {
	n := len(b)
	if n == 0 {
		return -1
	}
	if b[n-1] < a {
		return -1
	}
	l := 0
	r := n - 1
	for l < r {
		mid := (l + r) / 2
		if b[mid] >= a {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

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

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

package main

import "fmt"

func main(){
	var n int
	var arr []int
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		var num int
		fmt.Scanf("%d", &num)
		arr = append(arr, num)
	}

	for i := 0; i < n; i++ {
		if(judge(arr[i])){
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge(num int) bool {
	if num < 14 {
		return false
	}
	i := num % 14
	if i <= 6 && i >= 1 {
		return true
	}
	return false
}

package main

import "fmt"

func main(){
	var n int
	var arr []int
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		var num int
		fmt.Scanf("%d", &num)
		arr = append(arr, num)
	}

	for i := 0; i < n; i++ {
		if(judge(arr[i])){
			println("YES")
		} else {
			println("NO")
		}
	}
}

func judge(num int) bool {
	if num < 14 {
		return false
	}
	i := num % 14
	if i <= 6 && i >= 1 {
		return true
	}
	return false
}

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		n := 0
		fmt.Fscanf(in, "%d", &n)

		r := n % 14
		if r >= 1 && r <= 6 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}