let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    for(j = 1; j <= lines[0]; j ++){
        var l = lines[j].split(' ')
        var r = l[0]
        var b = l[1]
        var d = l[2]
        if(Math.abs(r - b) <= d*(Math.min(r, b))){
            console.log('YES')
        }else{
            console.log('NO')
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(var j = 1; j <= n; j++){
        var l = lines[j].split(' ');
        var r = l[0];
        var b = l[1];
        var d = l[2];
        if(Math.abs(r - b) <= d*Math.min(r, b)){
            console.log('YES');
        }else{
            console.log('NO');
        }
    }
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
   const test= readline();

   for(let i=0;i<test;i++){
     let r=readline().split(' ');

    //  console.log(Number(r[2])+1);
     console.log(solve(r));
    }

   }
function solve(r){
        const result =Math.min(r[0],r[1])*(Number(r[2])+1)>=Math.max(r[0],r[1])?"Yes":"No" ;
        return result;
    }

//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 getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
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 R = nextInt();
		var B = nextInt();
		var D = nextInt();
		if(R > B){
			var tmp = R;
			R = B;
			B = tmp;
		}
		var diff = B - R;
		var single = Math.ceil(diff / R);
		if(single <= D){
			myout("YES");
		}else{
			myout("NO");
		}
	}
}

/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ 747:
/***/ ((module) => {

module.exports = require("fs");;

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/************************************************************************/
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	(() => {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = (module) => {
/******/ 			var getter = module && module.__esModule ?
/******/ 				() => (module['default']) :
/******/ 				() => (module);
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	})();
/******/
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {

// EXTERNAL MODULE: external "fs"
var external_fs_ = __webpack_require__(747);
var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_);
;// CONCATENATED MODULE: external "readline"
const external_readline_namespaceObject = require("readline");;
;// CONCATENATED MODULE: ./src/lib/io.ts

class InteractiveIO {
  constructor() {
    this.rl = void 0;
    this.lines = [];
    this.rl = readline.createInterface({
      input: process.stdin,
      output: process.stdout
    });
    this.rl.on('line', line => {
      this.lines.push(line);
    });
  }

  nextLine() {
    return new Promise((resolve, reject) => {
      if (this.lines.length) {
        resolve(this.lines.shift());
        return;
      }

      let waitId = null;
      let timeoutId = null;
      waitId = setInterval(() => {
        if (this.lines.length) {
          resolve(this.lines.shift());
          clearTimeout(timeoutId);
          clearInterval(waitId);
          return;
        }
      }, 1);
      timeoutId = setTimeout(() => {
        clearInterval(waitId);
        reject(new Error('timeout')); // resolve(null);
      }, 500);
    });
  }

  close() {
    this.rl.close();
  }

}
class IO {
  constructor() {
    this.i = 0;
    this.text = '';
    this.out = '';
    this.readInput();
  }

  readInput() {
    this.text = __webpack_require__(747).readFileSync(0, 'utf8');
  }

  nextToken() {
    let ret = '';

    while (this.text[this.i].charCodeAt(0) <= 32) {
      this.i++;
    }

    while (this.i < this.text.length && this.text[this.i].charCodeAt(0) > 32) {
      ret += this.text[this.i];
      this.i++;
    }

    return ret;
  }

  nextNum() {
    return Number(this.nextToken());
  }

  nextBigInt() {
    return BigInt(this.nextToken());
  }

  nextNumArray(n) {
    let ret = [];

    while (n--) {
      ret.push(this.nextNum());
    }

    return ret;
  }

  _write(x) {
    this.out += x;
  }

  write(x) {
    this._write(x + ' ');
  }

  writeLine(x) {
    this._write(x + '\n');
  }

  flush() {
    external_fs_default().writeFileSync(1, this.out);
    this.out = '';
  }

}
;// CONCATENATED MODULE: ./src/cf-1519/1519-a.ts

const io = new IO();

function solve(r, b, d) {
  let min = Math.min(r, b);
  let max = Math.max(r, b);
  let rem = max - min;

  if (rem <= min * d) {
    io.writeLine('YES');
  } else {
    io.writeLine('NO');
  }
}

function main() {
  try {
    let t = io.nextNum();

    while (t--) {
      let r = io.nextNum();
      let b = io.nextNum();
      let d = io.nextNum();
      solve(r, b, d);
    }

    io.flush();
  } catch (e) {
    console.log(e.stack);
  }
}

main();

})();

/******/ })()
;

process.stdin.setEncoding('utf-8')
const readline = require('readline')

const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    }
)

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve([a, b, d]) {
    const s = Math.min(a, b);
    (Math.abs(a - b) / s <= d) ? console.log('YES') : console.log('NO')
}

function main() {
    for (let i = 0; i < inputArr.length; i++) solve(inputArr[i])
}

var t=+ readline();
while(t--){
    var input= readline();
    var arr= input.split(" ").map(x=>+x);
    var r=arr[0];
    var b=arr[1];
    var d=arr[2];
    if(r>b){
        var temp=r;
        r=b;
        b=temp;
    }
    var res=r*(d+1);
    if(res>=b)print("YES")
    else print("NO");
}

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

function candyShop(inp){
  let parsedInput = inp.split(' ')
                       .map(el=>Number( el)); // el.replace(/[^0-9]/g, '')
  if( parsedInput.length === 1 ) return null

  let [redAmount, blueAmount, maxDif] = [...parsedInput];
  if(maxDif===0) return redAmount===blueAmount ? 'yes' : 'no';

  let [min, max] = [Math.min(redAmount, blueAmount), Math.max(redAmount, blueAmount)],
      minDif = Math.ceil(max / min)-1;

  if(minDif > maxDif) return 'no'
  return 'yes'
}

rl.on('line', (input) => {
  let i = candyShop(input);
  if(i != null ){ console.log(i) }
});

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

function candyShop(inp){
  let parsedInput = inp.split(' ')
                       .map(el=>Number( el)); // el.replace(/[^0-9]/g, '')
  if( parsedInput.length === 1 ) return null

  let [redAmount, blueAmount, maxDif] = [...parsedInput];
  // if(maxDif===0) return redAmount===blueAmount ? 'yes' : 'no';

  let [min, max] = [Math.min(redAmount, blueAmount), Math.max(redAmount, blueAmount)],
      minDif = Math.ceil(max / min)-1;

  if(minDif > maxDif) return 'no'
  return 'yes'
}

rl.on('line', (input) => {
  let i = candyShop(input);
  if(i != null ){ console.log(i) }
});

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

function candyShop(inp){
  let parsedInput = inp.split(' ')
                       .map( el => Number( el.replace(/[^0-9]/g, '') ) ); // el.replace(/[^0-9]/g, '')
  if( parsedInput.length === 1 ) return null

  let [redAmount, blueAmount, maxDif] = [...parsedInput];
  if(maxDif===0) return redAmount===blueAmount ? 'yes' : 'no';

  let [min, max] = [Math.min(redAmount, blueAmount), Math.max(redAmount, blueAmount)],
      minDif = Math.ceil(max / min)-1;

  if(minDif > maxDif) return 'no'
  return 'yes'
}

rl.on('line', (input) => {
  let i = candyShop(input);
  if(i != null ){ console.log(i) }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    for(var j = 1; j <= n; j++){
        var l = lines[j].split(' ');
        var r = l[0];
        var b = l[1];
        var d = l[2];
        if(Math.abs(r - b) <= d * Math.min(r, b)){
            console.log('YES');
        }else{
            console.log('NO');
        }
    }
});

/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
var __webpack_exports__ = {};

;// CONCATENATED MODULE: ./src/io.js
var interact = function interact(main) {
  process.stdin.resume();
  process.stdin.setEncoding('utf-8');
  var inputString = '';
  var currentLine = 0;

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

  var print = function print() {
    for (var _len = arguments.length, any = new Array(_len), _key = 0; _key < _len; _key++) {
      any[_key] = arguments[_key];
    }

    process.stdout.write(any.join(' '));
  };

  var println = function println() {
    for (var _len2 = arguments.length, any = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
      any[_key2] = arguments[_key2];
    }

    any.length > 0 && print(any);
    print('\n');
  };

  var obj = {
    print: print,
    println: println,
    readline: readline
  };
  process.stdin.on('data', function (inputStdin) {
    inputString += inputStdin;
  });
  process.stdin.on('end', function () {
    inputString = inputString.trim().split('\n').map(function (string) {
      return string.trim();
    });
    main(obj);
  });
};

/* harmony default export */ const io = (interact);
;// CONCATENATED MODULE: ./src/index.js
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

var main = function main(io) {
  var tc = Number.parseInt(io.readline());

  while (tc--) {
    var _io$readline$split$ma = io.readline().split(' ').map(function (x) {
      return Number.parseInt(x);
    }),
        _io$readline$split$ma2 = _slicedToArray(_io$readline$split$ma, 3),
        r = _io$readline$split$ma2[0],
        b = _io$readline$split$ma2[1],
        d = _io$readline$split$ma2[2];

    if (r > b) {
      var temp = r;
      r = b;
      b = temp;
    } // assert r <= b

    var sat = b <= r * (1 + d);
    io.println(sat ? 'YES' : 'NO');
  }
};

io(main);
/******/ })()
;

'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(readLine());

    while(testCases--)
    {
        const [r,b,d] = get_ints();
        (Math.min(r,b) * (d + 1)) >= Math.max(r,b)  ? print('YES') : print('NO')

    }
});

function print(c){
    return console.log(c);
}

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

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

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

let currentLine = 0;
let inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

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

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

/******** Main function *************/

function main() {
  const t = +input();

  for (var i = 0; i < t; i++) {
    const [r, b, d] = input().split(" ").map(Number);

    const min = Math.min(r, b);
    const max = Math.max(r, b);

    const y = Math.ceil(max / min);

    if (d === 0) {
      if (r === b) {
        console.log("YES");
      } else {
        console.log("NO");
      }
    } else if (Math.abs(y - 1) > d) {
      console.log("NO");
    } else {
      console.log("YES");
    }
  }
}

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

function candyShop(inp){
  let parsedInput = inp.split(' ')
                       .map( el => Number( el.replace(/[^0-9]/g, '') ) );

  if( parsedInput.length === 1 ) return null

  let [redAmount, blueAmount, maxDif] = [...parsedInput];
  if(maxDif===0) return redAmount===blueAmount ? 'yes' : 'no';
  let [min, max] = [Math.min(redAmount, blueAmount), Math.max(redAmount, blueAmount)];
  if( Math.floor(max/min) <= maxDif ){ return 'yes'}
  else return 'no'
}

rl.on('line', (input) => {
  let i = candyShop(input);
  if(i != null ){ console.log(i) }
});

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

function candyShop(inp){
  let parsedInput = inp.split(' ')
                       .map( el => Number( el.replace(/[^0-9]/g, '') ) );

  if( parsedInput.length === 1 ) return 'no'

  let [redAmount, blueAmount, maxDif] = [...parsedInput];
  if(maxDif===0) return redAmount===blueAmount ? 'yes' : 'no';
  let [min, max] = [Math.min(redAmount, blueAmount), Math.max(redAmount, blueAmount)];
  if( Math.floor(max/min) <= maxDif ){ return 'yes'}
  else return 'no'
}

rl.on('line', (input) => {
  console.log( candyShop(input) )
});

const readline = require('readline');

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

function candyShop(redAmount, blueAmount, maxDif){
  if(maxDif===0) return redAmount===blueAmount ? console.log('yes') : console.log('no');
  if(Math.abs(redAmount-blueAmount)>maxDif) return console.log('no');
  if(redAmount<1 || blueAmount<1) return console.log('no');
  return console.log('yes')
}

rl.on('line', (input) => {
  if(input.length>1){ candyShop(input) }
});

/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
var __webpack_exports__ = {};

;// CONCATENATED MODULE: ./src/io.js
var interact = function interact(main) {
  process.stdin.resume();
  process.stdin.setEncoding('utf-8');
  var inputString = '';
  var currentLine = 0;

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

  var print = function print() {
    for (var _len = arguments.length, any = new Array(_len), _key = 0; _key < _len; _key++) {
      any[_key] = arguments[_key];
    }

    process.stdout.write(any.join(' '));
  };

  var println = function println() {
    for (var _len2 = arguments.length, any = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
      any[_key2] = arguments[_key2];
    }

    any.length > 0 && print(any);
    print('\n');
  };

  var obj = {
    print: print,
    println: println,
    readline: readline
  };
  process.stdin.on('data', function (inputStdin) {
    inputString += inputStdin;
  });
  process.stdin.on('end', function () {
    inputString = inputString.trim().split('\n').map(function (string) {
      return string.trim();
    });
    main(obj);
  });
};

/* harmony default export */ const io = (interact);
;// CONCATENATED MODULE: ./src/index.js
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

var main = function main(io) {
  var tc = Number.parseInt(io.readline());

  while (tc--) {
    var _io$readline$split$ma = io.readline().split(' ').map(function (x) {
      return Number.parseInt(x);
    }),
        _io$readline$split$ma2 = _slicedToArray(_io$readline$split$ma, 3),
        r = _io$readline$split$ma2[0],
        b = _io$readline$split$ma2[1],
        d = _io$readline$split$ma2[2];

    if (r > d) {
      var temp = r;
      r = b;
      b = temp;
    } // assert r <= b

    var sat = b <= r * (1 + d);
    io.println(sat ? 'YES' : 'NO');
  }
};

io(main);
/******/ })()
;

'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(readLine());

    while(testCases--)
    {
        const [r,b,d] = get_ints();

        if(r === b)
        {
            print('YES');
            continue;
        }
        const min = Math.min(r,b);
        const max = Math.max(r,b);
        Math.ceil(max/min) > d ? print('NO') : print('YES')

    }
});

function print(c){
    return console.log(c);
}

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

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

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

let currentLine = 0;
let inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

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

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

/******** Main function *************/

function main() {
  const t = +input();

  for (var i = 0; i < t; i++) {
    const [r, b, d] = input().split(" ").map(Number);

    const min = Math.min(r, b);
    const max = Math.max(r, b);

    const x = Math.floor(max / min);
    const y = Math.ceil(max / min);

    if (d === 0) {
      if (r === b) {
        console.log("YES");
      } else {
        console.log("NO");
      }
    } else if (d === 1) {
      if (Math.abs(max - min) > d) {
        console.log("NO");
      } else {
        console.log("YES");
      }
    } else if (min === 1) {
      if (max > d) {
        console.log("NO");
      } else {
        console.log("YES");
      }
    } else {
      if (Math.abs(x - y) > d) {
        console.log("NO");
      } else {
        console.log("YES");
      }
    }
  }
}


(function() {
var INPUT = ``;
var OUTPUT = ``;

var main = function() {"use strict";
    // TODO
    var t = rdN();
    while (t --> 0) {
        var input = rdArN();
        var b = input[0];
        var p = input[1];
        var f = input[2];
        var input = rdArN();
        var h = input[0];
        var c = input[1];

        if (h < c) {
            var buf = p;
            p = f;
            f = buf;
            var buf = h;
            h = c;
            c = buf;
        }
        var stack = crAr(p, h).concat(crAr(f, c)).reverse();
        var res = 0;
        while (b >= 2 && stack.length) {
            res += stack.pop();
            b -= 2;
        }
        pr(res);
    }
};

if(INPUT){INPUT=INPUT.split('\n').reverse();
readline=()=>INPUT.pop();
write=(...s)=>{OUTPUT+=[...s].join(' ')};
print=(...s)=>{write(...s);OUTPUT+='\n'};}
const
rdS=readline,
rdN=()=>+rdS(),
rdArS=()=>rdS().split(' '),
rdArN=()=>rdArS().map(v=>+v),
wr=write,
pr=print,
prAr=(a)=>pr(...a),
prOb=(o)=>pr(JSON.stringify(o,null,4)),
crAr=function(length,...fillArgs){return new Array(length).fill(...fillArgs);},
getPrimes=function(n){var sieve=crAr(n+1,true),primes=[],i,j;for(i=2,j=4;j<sieve.length;j=Math.pow(++i,2)){if(sieve[j]){for(;j<sieve.length;j+=i){sieve[j]=false;}}}for(i=2;i<sieve.length;++i){if(sieve[i]){primes.push(i);}}return primes;},
getPrimeFactors=function(n){var primes=getPrimes(Math.floor(Math.sqrt(n))),last=primes.push(n)-1,factors=[],i,p;for(i=0,p=primes[0];primes[last]>1;){if(primes[last]%p===0){primes[last]/=p;factors.push(p);}else{p=primes[++i];}}return factors;},
defineProperty=(o,pN,v)=>Object.defineProperty(o,pN,{value:v,writable:true,enumerable:false,configurable:true});
defineProperty(Array.prototype,'sortLt',function(){return this.sort((a,b)=>a-b);});
defineProperty(Array.prototype,'sortGt',function(){return this.sort((a,b)=>b-a);});

main();
return OUTPUT;
})();

var queries = readline();
for(var i = 0; i < queries; i++){
    var quantities = readline().split(' ');
    var b = parseInt(quantities[0]);
    var p = parseInt(quantities[1]);
    var f = parseInt(quantities[2]);

    var prices = readline().split(' ');
    var h = parseInt(prices[0]);
    var c = parseInt(prices[1]);

    var possibleBurgers = ~~(b / 2);
    //print("Burgers possible: " + possibleBurgers);

    if(h <= c){
        //print("Value of h and c: " + h + c);
        if(f >= possibleBurgers){
            print(possibleBurgers * c);
        }
        else{
            var h_bur_profit;
            var c_bur_profit = f * c;
            var remaining_possible_burgers = possibleBurgers - f;
            if(p <= remaining_possible_burgers){
                h_bur_profit = p * h;
            }
            else{
                h_bur_profit = remaining_possible_burgers * h;
            }
            print(h_bur_profit + c_bur_profit);
        }
    }
    else if(h > c){
        //print("Value of p and possible burgers: " + p + possibleBurgers);
        if(p >= possibleBurgers){
            print(possibleBurgers * h);
        }
        else{
            var h_bur_profit = p * h;
            var c_bur_profit;
            var remaining_possible_burgers = possibleBurgers - p;
            if(f <= remaining_possible_burgers){
                c_bur_profit = f * c;
            }
            else{
                c_bur_profit = remaining_possible_burgers * c;
            }
            print(h_bur_profit + c_bur_profit);
        }
    }
    else{
        print("0");
    }
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let count = 0;
let b, p, f;
let h, c;

const solve = () => {
  let ans = 0;
  const arr1 = new Array(p).fill(h);
  const arr2 = new Array(f).fill(c);

  for (let i = 1; i < b; i += 2) {
    if (h >= c) {
      ans += arr1.length ? arr1.pop() : arr2.pop() || 0;
    }
    else {
      ans += arr2.length ? arr2.pop() : arr1.pop() || 0;
    }
  }

  console.log(ans);
}

rl.on('line', (d) => {
  if (count === 0) {
    count++;
    return;
  }

  if (count % 2 === 1) {
    [b, p, f] = d.split(' ').map(Number);
  }
  else {
    [h, c] = d.split(' ').map(Number);

    solve();
  }

  count++;
});

'use strict';

let inputStr = '';
let lines = [];

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

process.stdin.on('end', () => {
  lines = inputStr.split('\n');
  lines.pop();
  main();
});

function main() {
  let b,p,f,h,c;
  for (let i = 1; i < lines.length; i += 2) {
    let curr = lines[i].split(' ');
    let total = 0;
    b = Math.floor(parseInt(curr[0], 10) / 2);
    p = parseInt(curr[1], 10);
    f = parseInt(curr[2], 10);
    curr = lines[i+1].split(' ');
    h = parseInt(curr[0], 10);
    c = parseInt(curr[1], 10);

    if (h > c) {
      while (b > 0 && p-- > 0) {
        total += h;
        b--;
      }
      while (b > 0 && f-- > 0) {
        total += c;
        b--;
      }
    } else {
      while (b > 0 && f-- > 0) {
        total += c;
        b--;
      }
      while (b > 0 && p-- > 0) {
        total += h;
        b--;
      }
    }

    console.log(total);
  }
}

var queries = readline();
for(var i = 0; i < queries; i++){
    var quantities = readline().split(' ');
    var b = quantities[0];
    var p = quantities[1];
    var f = quantities[2];

    var prices = readline().split(' ');
    var h = prices[0];
    var c = prices[1];

    var possibleBurgers = ~~(b / 2);
    //print("Burgers possible: " + possibleBurgers);

    if(possibleBurgers != 0 && h < c){
        if(f >= possibleBurgers){
            print(possibleBurgers * c);
        }
        else{
            var h_bur_profit;
            var c_bur_profit = f * c;
            var remaining_possible_burgers = possibleBurgers - f;
            if(p <= remaining_possible_burgers){
                h_bur_profit = p * h;
            }
            else{
                h_bur_profit = remaining_possible_burgers * h;
            }
            print(h_bur_profit + c_bur_profit);
        }
    }
    else if(possibleBurgers != 0 && h > c){
        if(p >= possibleBurgers){
            print(possibleBurgers * h);
        }
        else{
            var h_bur_profit = p * h;
            var c_bur_profit;
            var remaining_possible_burgers = possibleBurgers - p;
            if(f <= remaining_possible_burgers){
                c_bur_profit = f * c;
            }
            else{
                c_bur_profit = remaining_possible_burgers * c;
            }
            print(h_bur_profit + c_bur_profit);
        }
    }
    else{
        print("0");
    }
}


var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const n = rn();

		const ans = [];
		for (let i = 0; i < n; i++) {
			const a = rn();

			if (a == 1) {
				ans.push(1);
			} else {
				while (ans[ans.length-1] != a-1) ans.pop();
				ans[ans.length-1] += 1;
			}

			console.log(ans.join('.'));
		}
	}
}

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

function findAllStr(json, map, mapRev, index) {
   mapRev[index] = json;
   if (Array.isArray(json)) {
      for (var i = typeof json[0] === 'string' ? 1 : 0; i < json.length; i++) {
         findAllStr(json[i], map, mapRev, index + '_' + i);
      }
      return;
   }
   if (json && typeof json === 'string') {
      if (map[json]) {
         map[json].push(index);
      } else {
         map[json] = [index];
      }
   }
   return;
}

function solve() {
   var n = Number(read());
   var ans = [[1]];
   read();
   for (var i = 1; i < n; i++) {
      var a  = Number(read());
      ans[i] = ans[i - 1].slice();
      if (a === 1) {
         ans[i].push(1);
         continue;
      }
      var b = ans[i].pop();
      while(b + 1 !== a) {
         b = ans[i].pop();
      }
      ans[i].push(a);
   }
   write(ans.map((str) => str.join('.')).join('\n'));
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

function findAllStr(json, map, mapRev, index) {
   mapRev[index] = json;
   if (Array.isArray(json)) {
      for (var i = typeof json[0] === 'string' ? 1 : 0; i < json.length; i++) {
         findAllStr(json[i], map, mapRev, index + '_' + i);
      }
      return;
   }
   if (json && typeof json === 'string') {
      if (map[json]) {
         map[json].push(index);
      } else {
         map[json] = [index];
      }
   }
   return;
}

function addToStore(store, address, value) {
   if (!store[address]) {
      store[address] = [];
   }
   store[address].push(value);
}

function getFromStore(store, address) {
   return store[address].pop();
}

function solve() {
   var n = Number(read());
   var ans = [[1]];
   var store = [];
   addToStore(store, 2, 0);
   read();
   for (var i = 1; i < n; i++) {
      var a  = Number(read());
      if (a === 1) {
         ans[i] = ans[i - 1].slice();
         ans[i].push(1);
         addToStore(store, 2, i);
         continue;
      }
      var j = getFromStore(store, a);
      ans[i] = ans[j].slice();
      ans[i][ans[i].length - 1] = a;
      addToStore(store, a + 1, i);
   }
   write(ans.map((str) => str.join('.')).join('\n'));
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

var timer = 0;
function dfs(v, prev) {
   var h = {};
   v.__h = h;
   h.tin = ++timer;
   h.up = [];
   var i = 0;
   var next = prev;
   while (next) {
      h.up[i] = next;
      next = next.__h.up[i++];
   }
   var children = v.childNodes;
   for (i = 0; i < children.length; i++) {
      dfs(children[i], v);
   }
   h.tout = ++timer;
}

function findAllStr(json, map, mapRev, index) {
   mapRev[index] = json;
   if (Array.isArray(json)) {
      for (var i = typeof json[0] === 'string' ? 1 : 0; i < json.length; i++) {
         findAllStr(json[i], map, mapRev, index + '_' + i);
      }
      return;
   }
   if (json && typeof json === 'string') {
      if (map[json]) {
         map[json].push(index);
      } else {
         map[json] = [index];
      }
   }
   return;
}

function solve() {
   var n = Number(read());
   var ans = '0'.repeat(n).split('');
   ans[0] = [1];
   read();
   for (var i = 1; i < n; i++) {
      var a  = Number(read());
      if (a === 1) {
         ans[i] = ans[i - 1].slice();
         ans[i].push(1);
         continue;
      }
      var j = i - 1;
      while (ans[j][ans[j].length - 1] + 1 !== a) {
         j--;
      }
      ans[i] = ans[j].slice();
      ans[i][ans[i].length - 1] ++;
   }
   write(ans.map((str) => str.join('.')).join('\n'));
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

   var writeResult = '';
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}


var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        console.log(solve(lines[l++]));
    }
});

function solve(str) {
    const mid = Math.ceil(str.length / 2)

    let zero = 0
    for (let i = mid - 1; i >= 0; i--) {
        if (str[i] === '0') zero++
    }
    if ((str.length & 1) && str[mid - 1] === '0') {
        // alice change the middle 0 first
        // then convert to 0x0
        return zero === 1 ? 'BOB' : 'ALICE'
    }
    // 00x00 -> 10x00 -> 10x01, same with 0x0
    return 'BOB'
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let str = readline().trim();
    if (n === 1) {
      console.log("BOB");
      continue;
    }
    let cnt = 0;
    for (let i = 0; i < n; i++) if (str[i] === "0") cnt++;
    if(cnt===1) console.log("BOB");
    else if (cnt % 2) console.log("ALICE");
    else console.log("BOB");
  }
};
solve();

const palindromeDist = (line) => {
	let count = 0;
	for (let i=0; i<(line.length/2); i++) {
		if (line[i] !== line[line.length-1-i]) {
			count++;
		}
	}

	return count;
}

const solve = (line) => {
	const emptyCells = line.split('')
		.reduce((acc, item) => (acc += (item === '0' ? 1 : 0)), 0);

	if (emptyCells === 1) {
		return 'BOB';
	}

	const canDoPalindrome = line.length%2 === 1 && line[Math.floor(line.length/2)] === '0';

	return canDoPalindrome ? 'ALICE' : 'BOB';
}

let input = '';
process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
	const [n, ...lines] = input.trim().split('\n')
		.map(l => l.trim());

	for (let i=0; i<n; i++) {
		console.log(solve(lines[(i*2)+1]));
	}
})

var e=readline();
for(var iq=0;iq<e;iq++){
  var n=parseInt(readline());
  var s=readline();
  var zc=0;
  for(var i=0;i<s.length;i++){
    if(s[i]=='0') {
      zc++
    }
  }
  if(zc==0){
  print('DRAW');
  }else{
    if(zc==1){
    print('BOB');
    }else{
      if(zc%2==1){
        print('ALICE');
      }else{
        print('BOB');
      }
    }
  }
}

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
const isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 05/20/21 afternoon

const solve = (n, s) => {
    let cnt = 0;
    for (const c of s) cnt += (c == '0');
    // pr(cnt);
    if (n & 1 && s[n >>> 1] == '0' && cnt > 1) {
        pr("ALICE")
    } else {
        pr("BOB");
    }
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line);
    });
    rl.on('close', () => {
        let t = Number(input[0]);
        let i = 1;
        while (t--) {
            solve(input[i], input[i + 1]);
            i += 2;
        }
    });
};

main()

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let str = readline().trim();
    if (n === 1) {
      console.log("BOB");
      continue;
    }
    let cnt = 0;
    for (let i = 0; i < n; i++) if (str[i] === "0") cnt++;
    if (cnt % 2) console.log("ALICE");
    else console.log("BOB");
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let str = readline().trim();
    if (n === 1) console.log("BOB");
    let cnt = 0;
    for (let i = 0; i < n; i++) if (str[i] === "0") cnt++;
    if (cnt % 2) console.log("ALICE");
    else console.log("BOB");
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let str = readline().trim();
    if (n === 1) {
      if (str[0] === "0") console.log("BOB");
      else console.log("DRAW");
      continue;
    }
    let flag = true;
    for (let i = 0; i < n; i++) {
      if (str[i] !== str[n - 1 - i]) {
        flag = false;
        break;
      }
    }
    let cnt = 0,
      cnt1 = 0;
    for (let i = 0; i < n; i++) {
      if (str[i] === "0") cnt++;
    }
    let i = 0,
      j = n - 1;
    while (i <= j) {
      if (str[i] !== str[j]) cnt1++;
      i++;
      j--;
    }
    if (cnt === 0) {
      console.log("DRAW");
    } else if (cnt1 === 0) {
      if (cnt % 2) {
        console.log("ALICE");
      } else console.log("BOB");
    } else {
      let p2 = cnt1;
      cnt -= cnt1;
      if (cnt === 0) console.log("DRAW");
      else {
        if (cnt % 2 === 0) {
          p1 += Math.floor(n / 2);
          p2 += Math.floor(n / 2);
        } else {
          if (cnt === 1) p1 = 1;
          else if (cnt === 3) {
            p1 = 1;
            p2 += 2;
          } else {
            p2 += Math.floor(n / 2);
            p1 += cnt - Math.floor(n / 2);
          }
        }
        if (p1 === p2) console.log("DRAW");
        if (p1 < p2) console.log("ALICE");
        else console.log("BOB");
      }
    }
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let str = readline().trim();
    if (n === 1) {
      if (str[0] === "0") console.log("BOB");
      else console.log("DRAW");
      continue;
    }
    let flag = true;
    for (let i = 0; i < n; i++) {
      if (str[i] !== str[n - 1 - i]) {
        flag = false;
        break;
      }
    }
    let cnt = 0,
      cnt1 = 0;
    for (let i = 0; i < n; i++) {
      if (str[i] === "0") cnt++;
    }
    let i = 0,
      j = n - 1;
    while (i <= j) {
      if (str[i] !== str[j]) cnt1++;
      i++;
      j--;
    }
    if (cnt === 0) {
      console.log("DRAW");
    } else if (cnt1 === 0) {
      if (cnt % 2) {
        if (cnt === 3) console.log("ALICE");
        else console.log("BOB");
      } else console.log("BOB");
    } else {
      let p2 = cnt1;
      cnt -= cnt1;
      if (cnt === 0) console.log("DRAW");
      else {
        if (cnt % 2 === 0) {
          p1 += Math.floor(n / 2);
          p2 += Math.floor(n / 2);
        } else {
          if (cnt === 1) p1 = 1;
          else if (cnt === 3) {
            p1 = 1;
            p2 += 2;
          } else {
            p2 += Math.floor(n / 2);
            p1 += cnt - Math.floor(n / 2);
          }
        }
        if (p1 === p2) console.log("DRAW");
        if (p1 < p2) console.log("ALICE");
        else console.log("BOB");
      }
    }
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let str = readline().trim();
    if (n === 1) {
      if (str[0] === "0") console.log("BOB");
      else console.log("DRAW");
      continue;
    }
    let flag = true;
    for (let i = 0; i < n; i++) {
      if (str[i] !== str[n - 1 - i]) {
        flag = false;
        break;
      }
    }
    let cnt = 0,
      cnt1 = 0;
    for (let i = 0; i < n; i++) {
      if (str[i] === "0") cnt++;
    }
    let i = 0,
      j = n - 1;
    while (i <= j) {
      if (str[i] !== str[j]) cnt1++;
      i++;
      j--;
    }
    if (cnt === 0) {
      console.log("DRAW");
    } else if (cnt1 === 0) {
      if (cnt % 2) {
        cnt = Math.floor(cnt / 2) > cnt - Math.floor(cnt / 2) ? 0 : 1;
        if (cnt) console.log("ALICE");
        else console.log("BOB");
      } else console.log("BOB");
    } else {
      let p2 = cnt1;
      cnt -= cnt1;
      if (cnt === 0) console.log("DRAW");
      else {
        if (cnt % 2 === 0) {
          p1 += Math.floor(n / 2);
          p2 += Math.floor(n / 2);
        } else {
          if (cnt === 1) p1 = 1;
          else if (cnt === 3) {
            p1 = 1;
            p2 += 2;
          } else {
            p2 += Math.floor(n / 2);
            p1 += cnt - Math.floor(n / 2);
          }
        }
        if (p1 === p2) console.log("DRAW");
        if (p1 < p2) console.log("ALICE");
        else console.log("BOB");
      }
    }
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let str = readline().trim();
    if (n === 1) {
      if (str[0] === "0") console.log("BOB");
      else console.log("DRAW");
      continue;
    }
    let flag = true;
    for (let i = 0; i < n; i++) {
      if (str[i] !== str[n - 1 - i]) {
        flag = false;
        break;
      }
    }
    let cnt = 0,
      cnt1 = 0;
    for (let i = 0; i < n; i++) {
      if (str[i] === "0") cnt++;
    }
    let i = 0,
      j = n - 1;
    while (i <= j) {
      if (str[i] !== str[j]) cnt1++;
      i++;
      j--;
    }
    if (cnt === 0) {
      console.log("DRAW");
    } else if (cnt1 === 0) {
      if (cnt % 2) {
        cnt = Math.floor(cnt / 2) > cnt - Math.floor(cnt / 2) ? 0 : 1;
        if (cnt) console.log("ALICE");
        else console.log("BOB");
      } else console.log("BOB");
    } else {
      let p2 = cnt1,
        p1 = 0;
      let r = cnt - cnt1;
      if (r === 2) p1 += r;
      else {
        p2 += Math.floor(r / 2);
        p1 += r - Math.floor(r / 2);
      }
      if (p1 === p2) console.log("DRAW");
      else if (p1 < p2) console.log("ALICE");
      else console.log("BOB");
    }
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let str = readline().trim();
    if (n === 1) {
      if (str[0] === "0") console.log("BOB");
      else console.log("DRAW");
      continue;
    }
    let flag = true;
    for (let i = 0; i < n; i++) {
      if (str[i] !== str[n - 1 - i]) {
        flag = false;
        break;
      }
    }
    let cnt = 0,
      cnt1 = 0;
    for (let i = 0; i < n; i++) {
      if (str[i] === "0") cnt++;
    }
    let i = 0,
      j = n - 1;
    while (i <= j) {
      if (str[i] !== str[j]) cnt1++;
      i++;
      j--;
    }
    if (cnt === 0) {
      console.log("DRAW");
    } else if (cnt1 === 0) {
      if (cnt % 2) console.log("ALICE");
      else console.log("BOB");
    } else {
      let p2 = cnt1,
        p1 = 0;
      let r = cnt - cnt1;
      if (r === 2) p1 += r;
      else {
        p2 += Math.floor(r / 2);
        p1 += r - Math.floor(r / 2);
      }
      if (p1 === p2) console.log("DRAW");
      else if (p1 < p2) console.log("ALICE");
      else console.log("BOB");
    }
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let str = readline().trim();
    if (n === 1) {
      if (str[0] === "0") console.log("BOB");
      else console.log("DRAW");
      continue;
    }
    let flag = true;
    for (let i = 0; i < n; i++) {
      if (str[i] !== str[n - 1 - i]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      let ans = true;
      for (let i = 0; i < n; i++) {
        if (str[i] === "0") {
          ans = false;
          break;
        }
      }
      if (ans) console.log("DRAW");
      else console.log("BOB");
    } else {
      let cnt = 0,
        cnt1 = 0;
      for (let i = 0; i < n; i++) {
        if (str[i] === "0") cnt++;
      }
      let i = 0,
        j = n - 1;
      while (i <= j) {
        if (str[i] !== str[j]) cnt1++;
        i++;
        j--;
      }
      if (cnt % cnt1 === 0) console.log("DRAW");
      else console.log("ALICE");
    }
  }
};
solve();

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        console.log(solve(lines[l++]));
    }
});

function solve(str) {
    const mid = Math.ceil(str.length / 2)

    let zero = 0
    for (let i = mid - 1; i >= 0; i--) {
        if (str[i] === '0') zero++
    }
    if ((str.length & 1) && str[mid - 1] === '0') {
        // alice change the middle 0 first
        // then convert to 0x0
        return str.length === 1 ? 'BOB' : 'ALICE'
    }
    // 00x00 -> 10x00 -> 10x01, same with 0x0
    return 'BOB'
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        console.log(solve(lines[l++]));
    }
});

function solve(str) {
    const mid = Math.ceil(str.length / 2)

    let zero = 0
    for (let i = mid - 1; i >= 0; i--) {
        if (str[i] === '0') zero++
    }
    if ((str.length & 1) && str[mid - 1] === '0') {
        // alice change the middle 0 first
        // then convert to 0x0
        return 'ALICE'
    }
    // 00x00 -> 10x00 -> 10x01, same with 0x0
    return 'BOB'
}

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var t = parseInt(lines[0]);
    var l = 1;
    for (var i = 0; i < t; i++) {
        var n = +lines[l++]
        console.log(solve(lines[l++]));
    }
});

function solve(str) {
    const mid = Math.ceil(str.length / 2)
    let zero = 0
    for (let i = mid - 1; i >= 0; i--) {
        if (str[i] === '0') zero++
    }
    return (zero & 1) ? 'BOB' : 'DRAW'
}

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
const isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * 05/20/21 morning
 * https://codeforces.com/contest/1527/problem/B1
 */

const solve = (n, s) => {
    let se = new Set();
    for (let i = 0; i < n; i++) {
        if (s[i] == '0') se.add(i);
    }
    let a = s.split("");
    let Alice = Bob = 0;
    // replace '0' to '1' make s still palidrome in first priority
    let isP = true;
    let round = 1;
    let pre;
    // pr(a, se);
    // for (let i = 0; i <= 10; i++) {
    while (se.size) {
        if (isP == false && pre != 'rv') {
            // pr("reverse")
            a.reverse();
            pre = 'rv';
        } else {
            let did = false;
            for (const i of se) {
                if (i == n - 1 - i || a[n - 1 - i] == '1') {
                    a[i] = '1';
                    did = true; // still keep palidrome
                    // pr("111")
                    se.delete(i);
                    break;
                }
            }
            // pr(did)
            if (!did) {
                let first = se.values().next().value;
                // pr("2222", first, se)
                a[first] = '1';
                se.delete(first);
                isP = false;
            }
            round & 1 ? Alice++ : Bob++;
            pre = 'rp';
        }
        round++;
        // pr("next", a, se, isP, pre, Alice, Bob);
    }
    // pr(Alice, Bob);
    if (Alice > Bob) {
        pr("BOB");
    } else if (Alice < Bob) {
        pr("Alice");
    } else {
        pr("DRAW")
    }
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line);
    });
    rl.on('close', () => {
        let t = Number(input[0]);
        let i = 1;
        while (t--) {
            solve(input[i], input[i + 1]);
            i += 2;
        }
    });
};

main()

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
const isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * 05/20/21 morning
 * https://codeforces.com/contest/1527/problem/B1
 */

const solve = (n, s) => {
    let se = new Set();
    for (let i = 0; i < n; i++) {
        if (s[i] == '0') se.add(i);
    }
    let a = s.split("");
    let Alice = Bob = 0;
    // replace '0' to '1' make s still palidrome in first priority
    let isP = true;
    let round = 1;
    let pre;
    // pr(a, se);
    // for (let i = 0; i <= 10; i++) {
    while (se.size) {
        if (isP == false && pre != 'rv') {
            // pr("reverse")
            a.reverse();
            pre = 'rv';
        } else {
            let did = false;
            for (const i of se) {
                if (a[n - 1 - i] == '1') {
                    a[i] = '1';
                    did = true; // still keep palidrome
                    // pr("111")
                    se.delete(i);
                    break;
                }
            }
            // pr(did)
            if (!did) {
                let first = se.values().next().value;
                // pr("2222", first, se)
                a[first] = '1';
                se.delete(first);
                isP = false;
            }
            round & 1 ? Alice++ : Bob++;
            pre = 'rp';
        }
        round++;
        // pr("next", a, se, isP, pre, Alice, Bob);
    }
    // pr(Alice, Bob);
    if (Alice > Bob) {
        pr("BOB");
    } else if (Alice < Bob) {
        pr("Alice");
    } else {
        pr("DRAW")
    }
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line);
    });
    rl.on('close', () => {
        let t = Number(input[0]);
        let i = 1;
        while (t--) {
            solve(input[i], input[i + 1]);
            i += 2;
        }
    });
};

main()

var e=readline();
for(var iq=0;iq<e;iq++){
  var n=parseInt(readline());
  var s=readline();
  var r=true;
  for(var i=0;i<s.length;i++){
    if(s[i]=='0') {
      r=false;
    }
  }
  if(r){
  print('DRAW');
  }else{
    print('BOB');
  }
}


readline();
var inp = readline().split(' ').map(x => parseInt(x));

var max = Math.max(...inp);
var l_when_max = 0;

var indexes = [], i = -1;
while ((i = inp.indexOf(max, i+1)) != -1){
    indexes.push(i);
}

for(var j = 0 in indexes)
{
    var k = parseInt(j);
    var l = 1;
    while(k < indexes.length - 1 && indexes[k + 1] - indexes[k] === 1)
    {
        l++;
        k++;
    }

    if (l > l_when_max)
    {
        l_when_max = l;
    }
    if(l_when_max > indexes.length / 2)
    {
        break;
    }
}

print(l_when_max);

(function() {
    var read = {
        number: function() {
            return +readline();
        },
        arr: function(divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function(divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.number();
    var a = read.arrNumber(' ');

    var max = a[0];
    for(var i = 1; i < n; i++) {
        if(max < a[i]) max = a[i];
    }

    var count = [1];
    var countIndex = 0;
    for(var i = 1; i < n; i++) {
        if(a[i] === max) {
            if(a[i] === a[i - 1]) {
                count[countIndex] += 1;
            }
            else {
                countIndex++;
                count[countIndex] = 1;
            }
        }
    }

    max = count[0];
    for(var i = 1; i < n; i++) {
        if(max < count[i]) max = count[i];
    }
    print(max);

}());

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));
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 main() {
  const len = +readLine();
  const arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  let [maxLen, count, max] = [0, 0, Math.max(...arr)];

  for (let i = 0; i < len; i++) {
    if (arr[i] === max) {
      count++;
    } else {
      count = 0;
    }

    maxLen = Math.max(maxLen, count);
  }

  console.log(maxLen);
}

write((readline().split(" ").map(function(x) { return parseInt(x); })[0]*0 + readline().split(" ").reduce(function(acc, item) { var val = parseInt(item);  if (val > acc.mx) { acc.mx = val; acc.mx_cnt = 1; acc.ans = 1;} else if (val === acc.mx)	acc.mx_cnt++; else acc.mx_cnt = 0; acc.ans = Math.max(acc.ans, acc.mx_cnt); return acc;}, {mx: -1, mx_cnt: 0, ans: 1}).ans) + "\n");

function calc(arr) {
  // find max
  var max = 0;
  for (var i = 0; i< arr.length; i++) {
    max = max > arr[i] ? max : arr[i];
  }

  // find max count
  var count = 0;
  var countMax = 1;
  for (var i = 0; i< arr.length; i++) {
    if (arr[i] === max) {
      count++;
    } else {
      count = 0;
    }

    countMax = countMax > count ? countMax : count;
  }

  return countMax;
}

var n = parseInt(readline());
var arr = readline().split(" ").map(el => parseInt(el));

print(calc(arr));

var n = parseInt(readline(), 10),
    a = readline().split(' ').map(el => parseInt(el, 10)),
    max_mean = 0,
    max_len = 0,
    local_len = 0,
    local_mean = 0,
    local_sum = 0;

for(var i=0; i<n; i++) {
    if(a[i] > max_mean) {
        local_len = 1;
        local_sum = a[i];
        local_mean = local_sum / local_len;
    } else {
        local_len++;
        local_sum += a[i];
        local_mean = local_sum / local_len;
    }

    if(local_mean > max_mean) {
        max_mean = local_mean;
        max_len = local_len;

    } else if(local_mean === max_mean) {
        if(local_len > max_len) max_len = local_len;
    } else {
        local_len = 1;
        local_sum = a[i];
        local_mean = local_sum / local_len;

        if(local_mean > max_mean) {
            max_mean = local_mean;
            max_len = local_len;

        } else if(local_mean === max_mean) {
            if(local_len > max_len) max_len = local_len;
        }
    }
}

print(max_len);

readline();
var inp = readline().split(' ').map(x => parseInt(x));

var max = Math.max(...inp);
var l_when_max = 0;

var indexes = [], i = -1;
while ((i = inp.indexOf(max, i+1)) != -1){
    indexes.push(i);
}

print(indexes);

for(var j = 0 in indexes)
{
    var k = parseInt(j);
    var l = 1;
    while(k < indexes.length - 1 && indexes[k + 1] - indexes[k] === 1)
    {
        l++;
        k++;
    }

    if (l > l_when_max)
    {
        l_when_max = l;
    }
}

print(l_when_max);

write((readline().split(" ").map(function(x) { return parseInt(x); })[0]*0 + readline().split(" ").reduce(function(acc, item) { var val = parseInt(item);  if (val > acc.mx) { acc.mx = val; acc.mx_cnt = 1; } else if (val === acc.mx)	acc.mx_cnt++; else acc.mx_cnt = 0; acc.ans = Math.max(acc.ans, acc.mx_cnt); return acc;}, {mx: -1, mx_cnt: 0, ans: 1}).ans) + "\n");


//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 if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
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();
	while(hasNext()){
		var N = nextInt();
		var list = nextIntArray(N);
		var nzero = 0;
		for(var i = 0; i < N; i++){
			if(list[i] != 0){
				nzero++;
			}
		}
		if(nzero < N){
			myout(nzero);
		}else{
			var map = getCountMap(list);
			var key = Object.keys(map);
			if(key.length != N){
				myout(nzero);
			}else{
				myout(nzero + 1);
			}
		}
	}
}

'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 = parseInt(readline(), 10);
        let arr = readline().split(' ').map(Number);

        let zero = arr.findIndex(x => x === 0) > -1;
        let nonZero = arr.filter(x => x !== 0).length;

        let hash = {};

        let duplicate = false;
        for (let i = 0; i < n; i++) {
            if (arr[i] !== 0) {
                if (hash[arr[i]]) {
                    duplicate = true;
                } else {
                    hash[arr[i]] = 1;
                }
            }
        }

        output((zero || duplicate) ? nonZero : nonZero + 1);
    }
}

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

let lines = 0;
const hasUniqueElements = (arr) => {
  const cache = {};
  for (let index = 0; index < arr.length; index++) {
    const element = arr[index];
    if (!cache[element]) {
      cache[element] = true;
    } else {
      return false;
    }
  }
  return true;
};

const countAllZeros = (arr) => {
  zeros = 0;
  for (let index = 0; index < arr.length; index++) {
    const element = arr[index];
    if (element === 0) zeros++;
  }
  return zeros;
};

rl.on("line", function (line) {
  if (lines !== 0 && lines % 2 === 0) {
    let input = line.split(" ").map(Number);
    const zeros = countAllZeros(input);
    if (zeros > 0) {
      console.log(input.length - zeros);
    } else if (hasUniqueElements(input)) {
      console.log(input.length + 1);
    } else {
      console.log(input.length);
    }
  }
  lines++;
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    readLine();
    let arr = readLine().split(" ").map(i => parseInt(i)).sort((a, b) => a - b);
    let dup = false;
    let noofzeros = 0;
    let cnt = 0;
    if (arr[0] === 0) noofzeros = 1;
    for (let i = 1; i < arr.length; i++) {
        if ((arr[i] === arr[i - 1]) && !dup) dup = true;
        if (arr[i] === 0) noofzeros++;
    }
    cnt = arr.length - noofzeros;
    if (noofzeros == 0 && !dup)  return cnt + 1;
    if (noofzeros == 0 && dup) return cnt;
    else return cnt;
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    const map = {}
    let zero = 0
    let hasDup = 0
    arr.forEach(x => {
        if (!x) zero++
        if (map[x]) hasDup = 1
        map[x] = 1
    })
    if (zero) {
        return n - zero
    } else if (hasDup) {
        return n
    } else {
        return 1 + n
    }
}

'use strict';

var readline = require('readline');

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

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, a) {
  let zero = 0,
      repeat = 0,
      set = new Set();
  for (let num of a) {
    if (num === 0) {
      zero++;
    } else if (set.has(num)) {
      repeat = 1;
    }
    set.add(num);
  }
  if (zero > 0) {
    return n - zero;
  } else if (repeat > 0) {
    return n;
  } else {
    return n + 1;
  }
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const n = Number(await read());
    const a = (await read()).split(' ').map(Number);
    res.push(solve(n, a));
  }
  console.log(res.join('\n'));
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

const lines = [];
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.on('line', line => lines.push(line));
rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

const ra = ()=>readline().split(' ').map(a=>+a);

/*---------------------------------------------------*/

function div(val, by){
    return (val - val % by) / by;
}

const cnk = (n, k) => {
    let res = 1;
    for (let i = 1; i <= k; i++)
        res = res * (n - k + i) / i;
    return Math.round(res + 0.01);
}

const sumab = (a, b) => {
    let x = (b - a + 1);
    let y = a + b;
    if (x % 2 === 0) {
        x = Math.round(x / 2);
    } else {
        y = Math.round(y / 2);
    }
    return BigInt(x) * BigInt(y);
}

/*---------------------------------------------------*/

const calc = (n, a)=>{
    let zero = 0;
    let equal = false;

    a.sort((x, y) => x - y);

    let i = 0;
    while (i < n && a[i] === 0) {
        zero++;
        i++;
    }

    for (; i < n; i++) {
        if (i > 0 && a[i] === a[i - 1]) {
            equal = true;
            break;
        }
    }

    if (zero > 0) {
        return n - zero;
    } else {
        return equal ? n : n + 1;
    }
};

function main() {
    let T = +readline();
    // let out = [];
    for (let t = 1; t <= T; t++){
        let n = +readline();
        // let s = readline();
        let a = ra();
        // out.push(calc(n, s, a));
        process.stdout.write(`${calc(n, a)}\n`);
    }
    // process.stdout.write(out.join('\n')+'\n');
}

'use strict';
// HEADER:
const print = console.log;
let IS_MULTITEST, testN;
const pcalc = testN=>{
  let res = calc(testN);
  if (Array.isArray(res)){
    pa(res);
  } else if (Number.isFinite(res) || typeof res=='string'){
    print(res);
  }
};

const main = ()=>{
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(T);
  } else
   pcalc();
};

const lines = [];
const rl = require('readline').createInterface({
   input: process.stdin, output: process.stdout});
rl.on('line', line=>{
  lines.push(line);
});
rl.on('close', main);
let rli = 0;
const readline = ()=>lines[rli++];
const L = process.env.DEBUG ? console.log : ()=>{};
const LT = obj=>L(`Test #${testN}`, obj);

const ra = ()=>readline().split(' ').map(a=>+a)
const pa = arr=>print(arr.join(' '));

// SOLUTION:
IS_MULTITEST = 1;

const calc = ()=>{
  // READING:
  let [n] = ra();
  let A = ra();
  LT({n, A});

  // PROCESSING:
  let ans = 0;
  let left = 0;
  let cnt = {};
  let max = 0;
  for (let i=0; i<n; i++){
    let a = A[i];
    if (a>0)
      left++;
    cnt[a] = (cnt[a]||0)+1;
    max = Math.max(max, cnt[a])
  }
  if (left<n)
    return left;
  if (max>1){
    return n;
  }
  return n+1;
};

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var t = +readline();
root: for (var _i = 0, _a = Array.from(Array(t).keys()); _i < _a.length; _i++) {
    var i = _a[_i];
    var n = +readline();
    var a = readline().split(' ').map(function (v) { return +v; }).sort();
    if (a[0] === 0) {
        for (var j = 1; j < n; j++) {
            if (a[j] !== 0) {
                print(n - j);
                continue root;
            }
        }
        print(0);
        continue;
    }
    for (var i_1 = 1; i_1 < n; i_1++) {
        if (a[i_1] === a[i_1 - 1]) {
            print(n);
            continue root;
        }
    }
    print(n + 1);
}

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

let inputString = '';
let currentLine = 0;

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

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

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

const main = () => {
  let tc = parseInt(readline());
  while(tc--){
    const n = parseInt(readline());
    const a = readline().split(' ').map(Number);
    let zero = 0;
    for(let i = 0; i < n; i++){
      if(!a[i]) zero++;
    }
    if(zero){
      console.log(n-zero);
    }
    else{
      let same = false;
      for(let i = 0; i < n; i++){
        for(let j = i+1; j < n; j++){
          if(a[i] === a[j]) same = true;
        }
      }
      if(same){
        console.log(n);
      }
      else{
        console.log(n+1);
      }
    }
  }
};

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

let inputString = '';
let inputData = [];

process.stdin.on('data', inputStdin => {
  inputString = String(inputStdin);
});

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

const input = (() => {
  let line = 0;
  return () => inputData[line++];
})();

const main = () => {
  let tc = parseInt(input());
  while(tc--){
    const n = parseInt(input());
    const a = input().split(' ').map(Number);
    let zero = 0;
    for(let i = 0; i < n; i++){
      if(!a[i]) zero++;
    }
    if(zero){
      console.log(n-zero);
    }
    else{
      let same = false;
      for(let i = 0; i < n; i++){
        for(let j = i+1; j < n; j++){
          if(a[i] === a[j]) same = true;
        }
      }
      if(same){
        console.log(n);
      }
      else{
        console.log(n+1);
      }
    }
  }
};

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

let inputString = '';
let inputData = [];

process.stdin.on('data', inputStdin => {
  inputString = String(inputStdin);
});

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

const input = (() => {
  let line = 0;
  return () => inputData[line++];
})();

const main = () => {
  let tc = parseInt(input());
  while(tc--){
    const n = parseInt(input());
    const a = input().split(' ').map(Number);
    let zero = 0;
    for(let i = 0; i < n; i++){
      if(!a[i]) zero++;
    }
    if(zero){
      console.log(n-zero);
    }
    else{
      let same = false;
      for(let i = 0; i < n; i++){
        for(let j = 0; j < n; j++){
          if(i === j) continue;
          if(a[i] === a[j]) same = true;
        }
      }
      if(same){
        console.log(n);
      }
      else{
        console.log(n+1);
      }
    }
  }
};

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

let inputString = '';
let inputData = [];

process.stdin.on('data', inputStdin => {
  inputString = String(inputStdin);
});

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

const input = (() => {
  let line = 0;
  return () => inputData[line++];
})();

const main = () => {
  let tc = parseInt(input());
  while(tc--){
    let n = parseInt(input());
    const a = input().split(' ').map(Number);
    let zero = 0;
    for(let i = 0; i < n; i++){
      if(!a[i]) zero++;
    }
    if(zero){
      console.log(n-zero);
    }
    else{
      let same = false;
      for(let i = 0; i < n-1; i++){
        if(a[i] === a[i+1]) same = true;
      }
      if(same){
        console.log(n);
      }
      else{
        console.log(n+1);
      }
    }
  }
};

'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++) {
        readline();
        let arr = readline().split(' ').map(Number).filter(a => a !== 0);

        const freq = {};
        let equalPairs = 0;

        for (let i = 0; i < arr.length; i++) {
            if (freq[arr[i]]) {
                freq[arr[i]]++;
                if (freq[arr[i]] % 2 === 0) {
                    freq[arr[i]] = 0;
                    equalPairs++;
                }
            } else {
                freq[arr[i]] = 1;
            }
        }

        const remainingPairs = Math.ceil((arr.length - equalPairs * 2) / 2);

        output(equalPairs + remainingPairs * 2);
    }
}

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

let lines = 0;
const hasUniqueElements = (arr) => {
  const cache = {};
  for (let index = 0; index < arr.length; index++) {
    const element = arr[index];
    if (!cache[element]) {
      cache[element] = true;
    } else {
      return false;
    }
  }
  return true;
};

rl.on("line", function (line) {
  if (lines !== 0 && lines % 2 === 0) {
    let input = line.split(" ").map(Number);
    if (input.indexOf(0) !== -1) {
      console.log(input.length - 1);
    } else if (hasUniqueElements(input)) {
      console.log(input.length + 1);
    } else {
      console.log(input.length);
    }
  }
  lines++;
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    readLine();
    let arr = readLine().split(" ").map(i => parseInt(i));
    let hasZero = false;
    let dup = false;
    for (let i = 1; i < arr.length; i++) {
        if ((arr[i] === arr[i - 1]) && !dup) dup = true;
        if ((arr[i] == 0 || arr[i - 1] == 0) && !hasZero) hasZero = true;
    }
    if (hasZero) return arr.length - 1;
    else if (dup) return arr.length;
    else return arr.length + 1;
}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var t = +readline();
root: for (var _i = 0, _a = Array.from(Array(t).keys()); _i < _a.length; _i++) {
    var i = _a[_i];
    var n = +readline();
    var a = readline().split(' ').map(function (v) { return +v; }).sort();
    if (a[0] === 0) {
        print(n - 1);
        continue;
    }
    for (var i_1 = 1; i_1 < n; i_1++) {
        if (a[i_1] === a[i_1 - 1]) {
            print(n);
            continue root;
        }
    }
    print(n + 1);
}


'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString='';
let currentLine=0;
process.stdin.on('data',inputStdin=>{
    inputString+=inputStdin;
});
process.stdin.on('end',_=>{
    inputString=inputString.trim().split("\n").map(string=>{
        return string.trim();
    });
    main();
});
function readLine()
{
    return inputString[currentLine++];
}
function main()
{
    const k=parseInt(readLine());
    let mp=new Map();
    for(let t=0;t<k;++t)
    {
        const n=parseInt(readLine());
        let arr=readLine().trim().split(' ').map(x=>{return +(x.trim());});
        let sum=arr.reduce((a,b)=>a+b);
        for(let i=0;i<n;++i)
        {
            if(mp.get(sum-arr[i])!==undefined)
            {
                if(mp.get(sum-arr[i])[0]!=t)
                {
                    console.log("YES");
                    console.log((mp.get(sum-arr[i])[0]+1)+' '+(mp.get(sum-arr[i])[1]+1));
                    console.log((t+1)+' '+(i+1));
                    return;
                }
            }
            else
            {
                mp.set(sum-arr[i],[t,i]);
            }
        }
    }
    console.log("NO");
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString='';
let currentLine=0;
process.stdin.on('data',inputStdin=>{
    inputString+=inputStdin;
});
process.stdin.on('end',_=>{
    inputString=inputString.trim().split("\n").map(string=>{
        return string.trim();
    });
    main();
});
function readLine()
{
    return inputString[currentLine++];
}

function main()
{
    const K=parseInt(readLine());

    var seqSums = [];
    var seqs = []

    var map = new Map(); // key: sum - num, value: ["seqNo,removeItem", "seqNo,removeItem"]

    for (var i = 0; i < K; i++) {
        var len = parseInt(readLine());
        var seq=readLine().trim().split(' ').map(x=>{return +(x.trim());});
        var seqSum = 0;

        for (var j = 0; j < len; j++) {
            seqSum += seq[j];
        }

        for (var j = 0; j < len; j++) {
            if (map.get(seqSum - seq[j]) != undefined) {
                var tmp = map.get(seqSum - seq[j]);

                console.log("YES");
                tmp.forEach(function(item) {
                    console.log(item.split(',')[0] + " " + item.split(',')[1]);
                    console.log((i + 1) + " " + (j + 1));
                });

                map.set(seqSum - seq[j], tmp.push(i + "," + seq[j]));
                return;
            }
        }

        for (var j = 0; j < len; j++) {
            var tmp = [(i + 1) + "," + (j + 1)];
            map.set(seqSum - seq[j], tmp);
        }
    }
    console.log("NO");
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString='';
let currentLine=0;
process.stdin.on('data',inputStdin=>{
    inputString+=inputStdin;
});
process.stdin.on('end',_=>{
    inputString=inputString.trim().split("\n").map(string=>{
        return string.trim();
    });
    main();
});
function readLine()
{
    return inputString[currentLine++];
}

function main()
{
    const K=parseInt(readLine());

    var seqSums = [];
    var seqs = []

    var map = new Map(); // key: sum - num, value: ["seqNo,removeItem", "seqNo,removeItem"]

    for (var i = 0; i < K; i++) {
        var len = parseInt(readLine());
        var seq=readLine().trim().split(' ').map(x=>{return +(x.trim());});
        var seqSum = 0;

        for (var j = 0; j < len; j++) {
            seqSum += seq[j];
        }

        for (var j = 0; j < len; j++) {
            if (map.get(seqSum - seq[j]) != undefined) {
                var tmp = map.get(seqSum - seq[j]);

                console.log("YES");
                tmp.forEach(function(item) {
                    console.log((parseInt(item.split(',')[0]) + 1) + " " + item.split(',')[1]);
                    console.log((i + 1) + " " + seq[j]);
                });

                map.set(seqSum - seq[j], tmp.push(i + "," + seq[j]));
                return;
            }
        }

        for (var j = 0; j < len; j++) {
            var tmp = [i + "," + seq[j]];
            map.set(seqSum - seq[j], tmp);
        }
    }
    console.log("NO");
}


print(function(n, m) {

	var a = [];
	for (var i = 0; i < n; i++)
		a.push(readline().split(' ').map(Number));

	for (var i = 0; i < n; i++)
		for (var j = 0; j < m; j++)
			if ((i === 0 || i === n - 1 || j === 0 || j === m - 1) && a[i][j] === 1) return 2;

	return 4;

} .apply(0, readline().split(' ').map(Number)));

;(function () {
	print(function () {
		var l = readline().split(' ').map(Number), n = l[0], m = l[1];

		if (readline().split(' ').indexOf('1') !== -1) return 2;
		else n -= 2;

		while (n--) {
			l = readline().split(' ');
			if (l.indexOf('1') === 0 || l.lastIndexOf('1') === m - 1) return 2;
		}

		return readline().split(' ').indexOf('1') !== -1 ? 2 : 4;
	}());
}).call(this);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var rowNum = integers[0], colNum = integers[1];
	for (var r = 0; r < rowNum; ++r) {
		var row = tokenizeIntegers(readline());
		for (var c = 0; c < colNum; ++c) {
			if (row[c] == 1) {
				if (r == 0 || r == rowNum-1 || c == 0 || c == colNum-1) {
					print(2);
					return;
				}
			}
		}
	}
	print(4);
}

main();

;(function () {
	print(function () {
		var l = readline().split(' ').map(Number), n = l[0], m = l[1];

		l = readline().split(' ');
		if (l.indexOf('1') !== -1) return 2;
		else n -= 2;

		while (n--) {
			var i = readline().split(' ').indexOf('1');
			if (i === 0 || i === m - 1) return 2;
		}

		return readline().split(' ').indexOf('1') !== -1 ? 2 : 4;
	}());
}).call(this);