function readInt() {
  return Number(readline());
}

function readInts() {
  return readline().split(" ").map(Number);
}

var n = readInt();
var a = readInts();
var cnt = {};
a.forEach(function(x) {
  cnt[x] = (cnt[x] || 0) + 1;
});
var mx = 0;
for (var k in cnt) {
  mx = Math.max(mx, cnt[k]);
}
if (mx > Math.ceil(n / 2)) print("NO");
else print("YES");

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});

let length;
let list;
listCount = new Array(1001).fill(0);

rl.on('line', (line) => {
    if (!length) {
        length = parseInt(line);
        return;
    }
    list = line.split(' ').map(Number);
    let max = 0;
    for (let i = 0; i < list.length; i++) {
        listCount[list[i]]++;
        if (max < listCount[list[i]]) {
            max = listCount[list[i]];
        }
    }
    const half = length % 2 === 0 ? length / 2 : parseInt(length / 2) + 1;

    if (max > half) {
        console.log("NO");
    } else {
        console.log("YES");
    }

});

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  const len = +readLine();
  const map = new Map();
  const arr = readLine()
    .split(" ")
    .map((n) => {
      n = parseInt(n);
      map.set(n, (map.get(n) || 0) + 1);
      return n;
    });

  for (let [_, value] of map) {
    const diff = Math.abs(len - value);
    if (value > diff + 1) {
      console.log("NO");
      return;
    }
  }

  console.log("YES");
}

print(function(n) {
	var a = readline().split(' ');
	var b = new Int32Array(1005);
	for (var i = 0; i < n; i++)
		b[a[i]]++;

	var bMax = Math.max.apply(0, b);

	return bMax > (n + 1) / 2 ? 'NO' : 'YES';

}(+readline()));

print(function(n) {
	var b = new Int32Array(1005);
	readline().split(' ').forEach(function(v){
		b[v]++;
	});
	return Math.max.apply(0, b) > (n + 1) / 2 ? 'NO' : 'YES';
}(+readline()));

;(function () {

	var n = +readline();
	n = Math.ceil(n / 2);

	print((function () {
		for (var i = 0, str = readline().split(' '), m = {}, l = str.length; i < l; i++) {
			var k = Number(str[i]);
			m[k] = m[k] ? m[k] + 1 : 1;
			if (m[k] > n) return 'NO'
		}
		return 'YES';
	})());

}).call(this);

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = true;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp ;
        res = 'YES';
        for( i = 0 ; i < this.n ; i++ ) {
            this.vis[ this.arr[ i ] ]++ ;
        }
        for( i = 0 ; i <= 1000 ; i++ ) {
            if( this.vis[ i ] > Math.ceil( this.n / 2 ) ) {
                res = 'NO' ;
                break ;
            }
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 1010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr[ i ] = irObj.nextInt();
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.vis = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.vis.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        len = this.allLines[ this.currrentLineNumber ].length;
        if( flag == 0 ) {
            res = "";
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += this.allLines[ this.currrentLineNumber ][ i ];
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ][ i ] != ' ' ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = -1;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ][ i ] == ' ' ) {
                    endIdx = i;
                    break;
                }
                res += this.allLines[ this.currrentLineNumber ][ i ];
            }
            if( endIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            else {
                this.currrentCharacterIndex = endIdx;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectServerType = function() {
        var serverType = null ;
        try {
            //for nodejs local server check
            if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                serverType = 'local-node-js' ;
            }
        }
        catch( ex1 ) {
            try {
                if( readline == null || typeof( readline ) != 'function' ) {
                    serverType = 'server-node-js' ;
                }
                else {
                    serverType = 'javascript-v8' ;
                }
            }
            catch( ex2 ) {
                serverType = 'server-node-js' ;
            }
        }
        return serverType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , serverType ;
        isNodeJsJudgeServer = false ;
        serverType = this.detectServerType() ;
        if( serverType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( serverType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( serverType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();

print(function(n) {
	var b = new Int32Array(1005);
	readline().split('').forEach(function(v) {
		b[v]++;
	});
	return Math.max.apply(0, b) > (n + 1) / 2 ? 'NO' : 'YES';
}(+readline()));

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = true;

    this.solveCase = function() {
        var res , i , j , fl , cn ;
        res = 'YES';
        for( i = 1 ; i < this.n ; i++ ) {
            if( this.vis[ i ] == 0 ) {
                this.vis[ i ] = 1 ;
                fl = 0 ;
                cn = 0 ;
                for( j = 0 ; j < this.n ; j++ ) {
                    if( this.vis[ j ] == 0 && this.arr[ i ] != this.arr[ j ] ) {
                        this.vis[ j ] = 1 ;
                        fl = 1 ;
                        break ;
                    }
                    cn++ ;
                }
                if( fl == 0 && cn > 0 ) {
                    res = 'NO' ;
                    break ;
                }
            }
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 1010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr[ i ] = irObj.nextInt();
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.vis = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.vis.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        len = this.allLines[ this.currrentLineNumber ].length;
        if( flag == 0 ) {
            res = "";
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += this.allLines[ this.currrentLineNumber ][ i ];
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ][ i ] != ' ' ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = -1;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ][ i ] == ' ' ) {
                    endIdx = i;
                    break;
                }
                res += this.allLines[ this.currrentLineNumber ][ i ];
            }
            if( endIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            else {
                this.currrentCharacterIndex = endIdx;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectServerType = function() {
        var serverType = null ;
        try {
            //for nodejs local server check
            if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                serverType = 'local-node-js' ;
            }
        }
        catch( ex1 ) {
            try {
                if( readline == null || typeof( readline ) != 'function' ) {
                    serverType = 'server-node-js' ;
                }
                else {
                    serverType = 'javascript-v8' ;
                }
            }
            catch( ex2 ) {
                serverType = 'server-node-js' ;
            }
        }
        return serverType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , serverType ;
        isNodeJsJudgeServer = false ;
        serverType = this.detectServerType() ;
        if( serverType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( serverType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( serverType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = true;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp ;
        res = 'YES';
        for( i = 0 ; i < this.n - 1 ; i++ ) {
            fl = 0 ;
            cn = 0 ;
            for( j = i + 1 ; j < this.n ; j++ ) {
                if( this.arr[ i ] != this.arr[ j ] ) {
                    temp = this.arr[ j ] ;
                    this.arr[ j ] = this.arr[ i + 1 ] ;
                    this.arr[ i + 1 ] = temp ;
                    fl = 1 ;
                    break ;
                }
                cn++ ;
            }
            if( fl == 0 && cn > 0 ) {
                res = 'NO' ;
                break ;
            }
        }
        print( res );
    };

    this.init = function() {
        this.lim1 = 1010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr[ i ] = irObj.nextInt();
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.vis = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.vis.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        len = this.allLines[ this.currrentLineNumber ].length;
        if( flag == 0 ) {
            res = "";
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += this.allLines[ this.currrentLineNumber ][ i ];
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ][ i ] != ' ' ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = -1;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ][ i ] == ' ' ) {
                    endIdx = i;
                    break;
                }
                res += this.allLines[ this.currrentLineNumber ][ i ];
            }
            if( endIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            else {
                this.currrentCharacterIndex = endIdx;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectServerType = function() {
        var serverType = null ;
        try {
            //for nodejs local server check
            if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                serverType = 'local-node-js' ;
            }
        }
        catch( ex1 ) {
            try {
                if( readline == null || typeof( readline ) != 'function' ) {
                    serverType = 'server-node-js' ;
                }
                else {
                    serverType = 'javascript-v8' ;
                }
            }
            catch( ex2 ) {
                serverType = 'server-node-js' ;
            }
        }
        return serverType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , serverType ;
        isNodeJsJudgeServer = false ;
        serverType = this.detectServerType() ;
        if( serverType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( serverType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( serverType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();


let inputString = '';
let currentLine = 0;
process.stdin.on('data', (data) => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map((str) => str.trim());
	main();
});
function readLine() {
	return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
	for (var a = arguments, r = a[0], i = a.length; --i; )
		r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
	return r;
}
function inv(b) {
	for (var a = MOD, u = 0, v = 1, t; b; v = t)
		(t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
	u %= MOD;
	return u < 0 ? u + MOD : u;
}
function pow(base, n) {
	if (n === 0) return 1;
	let p = pow(base, Math.floor(n / 2));
	let res = mul(mod(p), mod(p));
	if (n % 2 === 1) res = mul(mod(res), base);
	return res;
}
function highestOneBit(i) {
	i |= i >> 1;
	i |= i >> 2;
	i |= i >> 4;
	i |= i >> 8;
	i |= i >> 16;
	return i - (i >>> 1);
}
function permutation(arr, len, store = '', permutations = []) {
	if (store.length === len) {
		permutations.push(store);
		return;
	}
	for (let i = 0; i < arr.length; i++) {
		const newArr = [...arr];
		const newChar = newArr.splice(i, 1);
		permutation(newArr, len, store.concat(newChar), permutations);
	}
	return permutations;
}
function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function main() {
	let t = +readLine();
	while (t--) {
		let [a, h, len] = readLine().split(' ').map(Number);
		let attacks = readLine().split(' ').map(Number);
		let healths = readLine().split(' ').map(Number);
		let flag = true;
		const enemy = [];

		for (let i = 0; i < len; i++) {
			let [ea, eh] = [attacks[i], healths[i]];
			enemy.push([ea, eh]);
		}
		enemy.sort((a, b) => a[0] - b[0]);
		const max = enemy.pop();

		for (let i = 0; i < enemy.length; i++) {
			let [ea, eh] = enemy[i];
			const div = Math.ceil(eh / a);
			h -= div * ea;
		}
		if (h > 0) {
			let [ea, eh] = [max[0], max[1]];
			const hRound = Math.ceil(eh / a);
			const eRound = Math.ceil(h / ea);
			if (hRound > eRound) console.log('NO');
			else console.log('YES');
		} else console.log('NO');
	}
}

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());
    let output = [];
    while(testCases--) {

        const [A,B,n] = readLine().split(' ').map(Number);
        const a = readLine().split(' ').map(Number);
        const b =readLine().split(' ').map(Number);

        const res = hero(A,B,n,a,b);
        output.push(res);
        //console.log(res);
    }
    console.log(output.join('\n'));
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function a(s){
    let finalString = '';
    let first = 97;
    let last = 122;
    for(let i = 0 ; i < s.length ; i++){
        let ascii = s[i].charCodeAt(0);
        if(i % 2 === 0){
            //alice turn
            if(ascii !== first){
                finalString += String.fromCharCode(first);
            } else {
                finalString += String.fromCharCode(first + 1);
            }
        } else {
            //Bob turn
            if(ascii !== last){
                finalString += String.fromCharCode(last);
            } else{
                finalString += String.fromCharCode(last - 1);
            }
        }
    }
    return finalString;
}

function hero(A,B,n,a,b){
    let monster = new Array(n);
    for(let i = 0; i< n; i++){
        monster[i] = [a[i], b[i]];
    }
    // sort monster by their attack power increasing order
    monster.sort((a,b) => a[0] - b[0]);

    for(let i = 0 ; i < n ; i++){
        // check if hero still alive?
        // console.log(monster[i])
        const [dmg, h] = monster[i];
        if(B <= 0) {
            return 'NO';
        }
        // how many fights to kill the monster?
        const count = Math.ceil(h / A);
        // how many fight a monster needs to kill a hero?
        const count2 = Math.ceil(B / dmg);
        // if a monster needs less fights to kill a hero than the hero cannot save the town
        // console.log('count = ', count, 'count2 = ', count2);
        if(count2 < count) return 'NO';
        // damage the hero
        B -= count * dmg;
        // console.log('B = ', B);
    }
    return 'YES';
}

module.exports = hero;

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var A = nextInt();
		var B = nextInt();
		var N = nextInt();
		var list = new Array(N);
		var alist = nextIntArray(N);
		var blist = nextIntArray(N);
		for(var j = 0; j < N; j++){
			list[j] = {
				a : alist[j],
				b : blist[j],
			};
		}
		list.sort(function(a,b){
			return a.a - b.a;
		});
		var isOK = true;
		for(var j = 0; j < N; j++){
			if(B <= 0){
				isOK = false;
				break;
			}
			var count = Math.ceil(list[j].b / A);
			var count2 = Math.ceil(B / list[j].a);
			if(count2 < count){
				isOK = false;
				break;
			}
			B -= count * list[j].a;
		}
		myout((isOK) ? "YES" : "NO");
	}
}

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const [A,B,n] = readLine().split(' ').map(Number);
        const a = readLine().split(' ').map(Number);
        const b =readLine().split(' ').map(Number);

        const res = hero(A,B,n,a,b);
        console.log(res);
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function a(s){
    let finalString = '';
    let first = 97;
    let last = 122;
    for(let i = 0 ; i < s.length ; i++){
        let ascii = s[i].charCodeAt(0);
        if(i % 2 === 0){
            //alice turn
            if(ascii !== first){
                finalString += String.fromCharCode(first);
            } else {
                finalString += String.fromCharCode(first + 1);
            }
        } else {
            //Bob turn
            if(ascii !== last){
                finalString += String.fromCharCode(last);
            } else{
                finalString += String.fromCharCode(last - 1);
            }
        }
    }
    return finalString;
}

function hero(A,B,n,a,b){
    let monster = new Array(n);
    for(let i = 0; i< n; i++){
        monster[i] = [a[i], b[i]];
    }
    // sort monster by their attack power increasing order
    monster.sort((a,b) => a[0] - b[0]);

    for(let i = 0 ; i < n ; i++){
        // check if hero still alive?
        // console.log(monster[i])
        const [dmg, h] = monster[i];
        if(B <= 0) {
            return 'NO';
        }
        // how many fights to kill the monster?
        const count = Math.ceil(h / A);
        // how many fight a monster needs to kill a hero?
        const count2 = Math.ceil(B / dmg);
        // if a monster needs less fights to kill a hero than the hero cannot save the town
        // console.log('count = ', count, 'count2 = ', count2);
        if(count2 < count) return 'NO';
        // damage the hero
        B -= count * dmg;
        // console.log('B = ', B);
    }
    return 'YES';
}

module.exports = hero;

const processData = (lines) => {
    let n = +lines[0]
    let cur = 0
    while(n--) {
        cur++
        let [A, B, n] = lines[cur].split(' ').map(x => +x)
        cur++
        const as = lines[cur].split(' ').map(x => +x)
        cur++
        const bs = lines[cur].split(' ').map(x => Math.ceil((+x)/A))
        let win = false
        for (let i=0; i<n; i++) {
            B -= as[i] * bs[i]
        }
        for (let i=0; i<n; i++) {
            if (B + as[i] > 0) {
                win = true
                break
            }
        }
        console.log(win ? 'YES' : 'NO')
    }
}

let i = []
process.stdin.on('data', c => i.push(c))
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.join('').split(EOL) /*your input text, split by lines*/
    processData(lines)
})

let inputString = '';
let currentLine = 0;
process.stdin.on('data', (data) => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map((str) => str.trim());
	main();
});
function readLine() {
	return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
	for (var a = arguments, r = a[0], i = a.length; --i; )
		r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
	return r;
}
function inv(b) {
	for (var a = MOD, u = 0, v = 1, t; b; v = t)
		(t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
	u %= MOD;
	return u < 0 ? u + MOD : u;
}
function pow(base, n) {
	if (n === 0) return 1;
	let p = pow(base, Math.floor(n / 2));
	let res = mul(mod(p), mod(p));
	if (n % 2 === 1) res = mul(mod(res), base);
	return res;
}
function highestOneBit(i) {
	i |= i >> 1;
	i |= i >> 2;
	i |= i >> 4;
	i |= i >> 8;
	i |= i >> 16;
	return i - (i >>> 1);
}
function permutation(arr, len, store = '', permutations = []) {
	if (store.length === len) {
		permutations.push(store);
		return;
	}
	for (let i = 0; i < arr.length; i++) {
		const newArr = [...arr];
		const newChar = newArr.splice(i, 1);
		permutation(newArr, len, store.concat(newChar), permutations);
	}
	return permutations;
}
function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function main() {
	let t = +readLine();
	while (t--) {
		let [a, h, len] = readLine().split(' ').map(Number);
		let attacks = readLine().split(' ').map(Number);
		let healths = readLine().split(' ').map(Number);
		let flag = true;

		for (let i = 0; i < len; i++) {
			let [ea, eh] = [attacks[i], healths[i]];
			const div = Math.floor(eh / a);
			const rem = eh % a;
			const totalAttack = div + rem;

			if (h > 0) {
				h -= totalAttack * ea;
				healths[i] = 0;
			}
		}
		let count = 0;
		for (let i = 0; i < len; i++) {
			let [ea, eh] = [attacks[i], healths[i]];
			if (eh <= 0) count++;
		}

		if (count === len) {
			if (h <= 0) {
				if (Math.abs(h) <= attacks[len - 1]) {
					console.log('YES');
				} else {
					console.log('NO');
				}
			} else console.log('YES');
		} else console.log('NO');
	}
}

let inputString = '';
let currentLine = 0;
process.stdin.on('data', (data) => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map((str) => str.trim());
	main();
});
function readLine() {
	return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
	for (var a = arguments, r = a[0], i = a.length; --i; )
		r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
	return r;
}
function inv(b) {
	for (var a = MOD, u = 0, v = 1, t; b; v = t)
		(t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
	u %= MOD;
	return u < 0 ? u + MOD : u;
}
function pow(base, n) {
	if (n === 0) return 1;
	let p = pow(base, Math.floor(n / 2));
	let res = mul(mod(p), mod(p));
	if (n % 2 === 1) res = mul(mod(res), base);
	return res;
}
function highestOneBit(i) {
	i |= i >> 1;
	i |= i >> 2;
	i |= i >> 4;
	i |= i >> 8;
	i |= i >> 16;
	return i - (i >>> 1);
}
function permutation(arr, len, store = '', permutations = []) {
	if (store.length === len) {
		permutations.push(store);
		return;
	}
	for (let i = 0; i < arr.length; i++) {
		const newArr = [...arr];
		const newChar = newArr.splice(i, 1);
		permutation(newArr, len, store.concat(newChar), permutations);
	}
	return permutations;
}
function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function main() {
	let t = +readLine();
	while (t--) {
		let [a, h, len] = readLine().split(' ').map(Number);
		let attacks = readLine().split(' ').map(Number);
		let healths = readLine().split(' ').map(Number);
		let flag = true;

		for (let i = 0; i < len; i++) {
			let [ea, eh] = [attacks[i], healths[i]];
			const div = Math.floor(eh / a);
			const rem = eh % a;
			const totalAttack = div + rem;

			if ((totalAttack > 1 && h > (totalAttack - 1) * ea) || (totalAttack === 1 && h > 0)) {
				h -= totalAttack * ea;
				healths[i] = 0;
			} else {
				flag = false;
				break;
			}
		}

		if (flag) console.log('YES');
		else console.log('NO');
	}
}

let inputString = '';
let currentLine = 0;
process.stdin.on('data', (data) => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map((str) => str.trim());
	main();
});
function readLine() {
	return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
	for (var a = arguments, r = a[0], i = a.length; --i; )
		r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
	return r;
}
function inv(b) {
	for (var a = MOD, u = 0, v = 1, t; b; v = t)
		(t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
	u %= MOD;
	return u < 0 ? u + MOD : u;
}
function pow(base, n) {
	if (n === 0) return 1;
	let p = pow(base, Math.floor(n / 2));
	let res = mul(mod(p), mod(p));
	if (n % 2 === 1) res = mul(mod(res), base);
	return res;
}
function highestOneBit(i) {
	i |= i >> 1;
	i |= i >> 2;
	i |= i >> 4;
	i |= i >> 8;
	i |= i >> 16;
	return i - (i >>> 1);
}
function permutation(arr, len, store = '', permutations = []) {
	if (store.length === len) {
		permutations.push(store);
		return;
	}
	for (let i = 0; i < arr.length; i++) {
		const newArr = [...arr];
		const newChar = newArr.splice(i, 1);
		permutation(newArr, len, store.concat(newChar), permutations);
	}
	return permutations;
}
function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function main() {
	let t = +readLine();
	while (t--) {
		let [a, h, len] = readLine().split(' ').map(Number);
		let attacks = readLine().split(' ').map(Number);
		let healths = readLine().split(' ').map(Number);
		let flag = true;

		for (let i = 0; i < len; i++) {
			let [ea, eh] = [attacks[i], healths[i]];
			const div = Math.floor(eh / a);
			const rem = eh % a;
			const totalAttack = div + rem;
			if (h > (totalAttack - 1) * ea) {
				h -= totalAttack * ea;
				healths[i] = 0;
			} else {
				flag = false;
				break;
			}
		}

		if (flag) console.log('YES');
		else console.log('NO');
	}
}

let inputString = '';
let currentLine = 0;
process.stdin.on('data', (data) => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map((str) => str.trim());
	main();
});
function readLine() {
	return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
	for (var a = arguments, r = a[0], i = a.length; --i; )
		r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
	return r;
}
function inv(b) {
	for (var a = MOD, u = 0, v = 1, t; b; v = t)
		(t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
	u %= MOD;
	return u < 0 ? u + MOD : u;
}
function pow(base, n) {
	if (n === 0) return 1;
	let p = pow(base, Math.floor(n / 2));
	let res = mul(mod(p), mod(p));
	if (n % 2 === 1) res = mul(mod(res), base);
	return res;
}
function highestOneBit(i) {
	i |= i >> 1;
	i |= i >> 2;
	i |= i >> 4;
	i |= i >> 8;
	i |= i >> 16;
	return i - (i >>> 1);
}
function permutation(arr, len, store = '', permutations = []) {
	if (store.length === len) {
		permutations.push(store);
		return;
	}
	for (let i = 0; i < arr.length; i++) {
		const newArr = [...arr];
		const newChar = newArr.splice(i, 1);
		permutation(newArr, len, store.concat(newChar), permutations);
	}
	return permutations;
}
function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function main() {
	let t = +readLine();
	while (t--) {
		let [a, h, len] = readLine().split(' ').map(Number);
		let attacks = readLine().split(' ').map(Number);
		let healths = readLine().split(' ').map(Number);
		let flag = true;

		for (let i = 0; i < len; i++) {
			let [ea, eh] = [attacks[i], healths[i]];
			const div = Math.floor(eh / a);
			if (h > 0) {
				eh = eh - div * a;
				h -= div * ea;
				healths[i] = eh;
			} else {
				flag = false;
				break;
			}
		}
		if (flag) {
			for (let i = 0; i < len; i++) {
				const [ea, eh] = [attacks[i], healths[i]];
				if (eh > 0 && h > 0) {
					h -= ea;
				} else if (eh > 0 && h <= 0) {
					flag = false;
					break;
				}
			}
			if (flag) console.log('YES');
			else console.log('NO');
		} else {
			console.log('NO');
		}
	}
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var A = nextInt();
		var B = nextInt();
		var N = nextInt();
		var list = new Array(N);
		var alist = nextIntArray(N);
		var blist = nextIntArray(N);
		for(var j = 0; j < N; j++){
			list[j] = {
				A : alist[j],
				B : blist[j],
				req : Math.ceil(blist[j] / A) * alist[j]
			};
		}
		list.sort(function(a,b){
			return a.req - b.req;
		});
		var isOK = true;
		for(var j = 0 ; j < N; j++){
			var MtoHcount = Math.ceil(B / list[j].A);
			var HtoMcount = Math.ceil(list[j].B / A);
			if(HtoMcount > MtoHcount){
				isOK = false;
				break;
			}
			B -= HtoMcount * list[j].A;
			if(j < N - 1 && B <= 0){
				isOK = false;
				break;
			}
		}
		myout((isOK) ? "YES" : "NO");
	}
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var A = nextInt();
		var B = nextInt();
		var N = nextInt();
		var alist = nextIntArray(N);
		var blist = nextIntArray(N);
		var isOK = true;
		for(var j = 0 ; j < N; j++){
			var HtoMcount = Math.ceil(blist[j] / A);
			var MtoHcount = Math.ceil(B / alist[j]);
			if(HtoMcount > MtoHcount){
				isOK = false;
				break;
			}
			B -= HtoMcount * alist[j];
			if(j < N - 1 && B <= 0){
				isOK = false;
			}
		}
		myout((isOK) ? "YES" : "NO");
	}
}

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const [A,B,n] = readLine().split(' ').map(Number);
        const a = readLine().split(' ').map(Number);
        const b =readLine().split(' ').map(Number);

        const res = hero(A,B,n,a,b);
        console.log(res);
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function a(s){
    let finalString = '';
    let first = 97;
    let last = 122;
    for(let i = 0 ; i < s.length ; i++){
        let ascii = s[i].charCodeAt(0);
        if(i % 2 === 0){
            //alice turn
            if(ascii !== first){
                finalString += String.fromCharCode(first);
            } else {
                finalString += String.fromCharCode(first + 1);
            }
        } else {
            //Bob turn
            if(ascii !== last){
                finalString += String.fromCharCode(last);
            } else{
                finalString += String.fromCharCode(last - 1);
            }
        }
    }
    return finalString;
}

function hero(A,B,n,a,b){
    const monster = new Array(n);
    for(let i = 0; i< n; i++){
        monster[i] = [a[i], b[i]];
    }
    // console.log(monster);
    monster.sort((a,b) => a[0] > b[0]);
    // console.log(monster);
    for(let i = 0 ; i < n ; i++){
        // check if hero still alive?
        if(B <= 0) {
            return 'NO';
        }
        // how many fights to kill the monster?
        const count = Math.ceil(monster[i][1] / A);
        // how many fight a monster needs to kill a hero?
        const count2 = Math.ceil(B / monster[i][0]);
        // if a monster needs less fights to kill a hero than the hero cannot save the town
        if(count2 < count) return 'NO';
        // damage the hero
        B -= count * a[i];
    }
    return 'YES';
}

module.exports = hero;

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const [A,B,n] = readLine().split(' ').map(Number);
        const a = readLine().split(' ').map(Number);
        const b =readLine().split(' ').map(Number);

        const res = hero(A,B,n,a,b);
        console.log(res);
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function a(s){
    let finalString = '';
    let first = 97;
    let last = 122;
    for(let i = 0 ; i < s.length ; i++){
        let ascii = s[i].charCodeAt(0);
        if(i % 2 === 0){
            //alice turn
            if(ascii !== first){
                finalString += String.fromCharCode(first);
            } else {
                finalString += String.fromCharCode(first + 1);
            }
        } else {
            //Bob turn
            if(ascii !== last){
                finalString += String.fromCharCode(last);
            } else{
                finalString += String.fromCharCode(last - 1);
            }
        }
    }
    return finalString;
}

function hero(A,B,n,a,b){
    let monster_health = b.reduce((a,b) => a + b);
    const hero_health = B;
    for(let i = 0 ; i < n ; i++){
        // check if hero still alive?
        if(B <= 0) {
            return 'NO';
        }
        // how many fights to kill the monster?
        const count = Math.ceil(b[i] / A);
        // how many fight a monster needs to kill a hero?
        const count2 = Math.ceil(B / a[i]);
        // if a monster needs less fights to kill a hero than the hero cannot save the town
        if(count2 < count) return 'NO';
        // damage the hero
        B -= count * a[i];
    }
    return 'YES';
}

module.exports = hero;

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

process.stdin.on('data', chunk => {
data += chunk;
});

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const [A,B,n] = readLine().split(' ').map(Number);
        const a = readLine().split(' ').map(Number);
        const b =readLine().split(' ').map(Number);

        const res = hero(A,B,n,a,b);
        console.log(res);
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

function readLine() {
        return data[currentLine++];
}

function a(s){
    let finalString = '';
    let first = 97;
    let last = 122;
    for(let i = 0 ; i < s.length ; i++){
        let ascii = s[i].charCodeAt(0);
        if(i % 2 === 0){
            //alice turn
            if(ascii !== first){
                finalString += String.fromCharCode(first);
            } else {
                finalString += String.fromCharCode(first + 1);
            }
        } else {
            //Bob turn
            if(ascii !== last){
                finalString += String.fromCharCode(last);
            } else{
                finalString += String.fromCharCode(last - 1);
            }
        }
    }
    return finalString;
}

function hero(A,B,n,a,b){
    //amount of monster health
    // console.log('A = ', A, 'B = ', B, 'n = ', n, 'a = ', a, 'b = ', b);
    let curr_healt = B;
    for(let i = 0 ; i < n; i++){
        if(curr_healt <= 0 )  {
            return 'NO';
            }
        // calc how many fight needs to finnish the monster?
        let count = Math.ceil(b[i]/A);
        curr_healt = curr_healt - (a[i] * count);
        if(curr_healt <= 0 && i == n - 1){
            curr_healt = Math.min(curr_healt + (a[i] * count), B);
            while(curr_healt > 0 || b[i] > 0){
                curr_healt -= a[i];
                b[i] -= A;
                if(curr_healt <= 0 || b[i] <= 0) break;
            }
            if(b[i] <= 0 ){
                return 'YES';
            } else {
                return 'NO';
            }
        }
    }
    return 'YES';
}

module.exports = hero;


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', stdin => inputString += stdin);

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(s => s.trim());
    main();
});

function readline() {
    return inputString[currentLine++];
}

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let [n, k, r, c] = readline().split(' ').map(Number);

        let rmod = r % k;
        let cmod = c % k;

        let top = [];
        let bottom = [];

        let cmod1 = cmod;
        for (let row = r; row <= n; row++) {
            let line = '';

            for (let col = 1; col <= n; col++) {
                if (col % k === cmod1) line += 'X'; else line += '.';
            }
            top.push(line);
            cmod1++;
            if (cmod1 === k) cmod1 = 0;
        }

        let cmod2 = cmod - 1;
        if (cmod2 < 0) cmod2 = k - 1;
        if (r > 1) {
            for (let row = r - 1; row > 0; row--) {
                let line = '';

                for (let col = 1; col <= n; col++) {
                    if (col % k === cmod2) line += 'X'; else line += '.';
                }
                bottom.push(line);
                cmod2--;
                if (cmod2 < 0) cmod2 = k - 1;
            }
        }

        bottom.reverse();

        let arr = [...bottom, ...top];

        for (let i = 0; i < arr.length; i++) {
            output(arr[i]);
        }
    }
}

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  let [n, k, r, c] = rns(4);
  r--;
  c--;
  r = r % k;
  c = c % k;
  const res = Array.from({
    length: n
  }, () => new Array(n).fill('.'));
  for (let i = 0; i < k; i++) {
    res[r][c] = 'X';
    r = (r + 1) % k;
    c = (c + 1) % k;
  }
  for (let i = 0; i < n; i++) {
    for (let j = 0; j < n; j++) {
      res[i][j] = res[i % k][j % k];
    }
  }
  return res.map(arr => arr.join('')).join('\n');
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn();
    return res;
  };
  const re = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn() - 1;
    return res;
  };
  const rbs = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rb();
    return res;
  };
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  const [rn, rb, rns, re, rbs] = convertInput(r);
  try {
    let t = rn();
    let res = new Array(t);
    let limit = 100;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();