This is the hard version of this problem. The difference between easy and hard versions is only the constraints on $$$a_i$$$ and on $$$n$$$. You can make hacks only if both versions of the problem are solved.Burenka is the crown princess of Buryatia, and soon she will become the $$$n$$$-th queen of the country. There is an ancient tradition in Buryatia — before the coronation, the ruler must show their strength to the inhabitants. To determine the strength of the $$$n$$$-th ruler, the inhabitants of the country give them an array of $$$a$$$ of exactly $$$n$$$ numbers, after which the ruler must turn all the elements of the array into zeros in the shortest time. The ruler can do the following two-step operation any number of times:   select two indices $$$l$$$ and $$$r$$$, so that $$$1 \le l \le r \le n$$$ and a non-negative integer $$$x$$$, then  for all $$$l \leq i \leq r$$$ assign $$$a_i := a_i \oplus x$$$, where $$$\oplus$$$ denotes the bitwise XOR operation. It takes $$$\left\lceil \frac{r-l+1}{2} \right\rceil$$$ seconds to do this operation, where $$$\lceil y \rceil$$$ denotes $$$y$$$ rounded up to the nearest integer. Help Burenka calculate how much time she will need.

The first line contains a single integer $$$t$$$ $$$(1 \le t \le 500)$$$  — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(1 \le n \le 10^5)$$$ - the size of the array The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \cdots , a_n$$$ $$$(0 \le a_i < 2^{30})$$$ — elements of the array. It is guaranteed that the sum of $$$n$$$ in all tests does not exceed $$$10^5$$$.

For each test case, output a single number  — the minimum time that Burenka will need.

NoteIn the first test case, Burenka can choose segment $$$l = 1$$$, $$$r = 4$$$, and $$$x=5$$$. so it will fill the array with zeros in $$$2$$$ seconds.In the second test case, Burenka first selects segment $$$l = 1$$$, $$$r = 2$$$, and $$$x = 1$$$, after which $$$a = [0, 2, 2]$$$, and then the segment $$$l = 2$$$, $$$r = 3$$$, and $$$x=2$$$, which fills the array with zeros. In total, Burenka will spend $$$2$$$ seconds.

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 dp = Array(n)
    const m = {}
    m[0] = -1
    let xor = 0
    for (let i = 0; i < n; i++) {
        dp[i] = (dp[i - 1] || 0) + (arr[i] ? 1 : 0)
        xor ^= arr[i]
        if (xor in m) {
            const j = m[xor]
            // [j + 1, i]
            dp[i] = Math.min(dp[i], (dp[j] || 0) + (i - j - 1))
            // console.log(j + 1, i)
        // } else {
        }
        m[xor] = i
    }
    // console.log(dp)
    return dp[n - 1]
}


You are given an array $$$a_1, a_2, \dots , a_n$$$, which is sorted in non-decreasing order ($$$a_i \le a_{i + 1})$$$. Find three indices $$$i$$$, $$$j$$$, $$$k$$$ such that $$$1 \le i < j < k \le n$$$ and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to $$$a_i$$$, $$$a_j$$$ and $$$a_k$$$ (for example it is possible to construct a non-degenerate triangle with sides $$$3$$$, $$$4$$$ and $$$5$$$ but impossible with sides $$$3$$$, $$$4$$$ and $$$7$$$). If it is impossible to find such triple, report it.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$3 \le n \le 5 \cdot 10^4$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$; $$$a_{i - 1} \le a_i$$$) — the array $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case print the answer to it in one line. If there is a triple of indices $$$i$$$, $$$j$$$, $$$k$$$ ($$$i < j < k$$$) such that it is impossible to construct a non-degenerate triangle having sides equal to $$$a_i$$$, $$$a_j$$$ and $$$a_k$$$, print that three indices in ascending order. If there are multiple answers, print any of them. Otherwise, print -1.

NoteIn the first test case it is impossible with sides $$$6$$$, $$$11$$$ and $$$18$$$. Note, that this is not the only correct answer.In the second test case you always can construct a non-degenerate triangle.

var readline=require('readline');
var rl=readline.createInterface({
    input:process.stdin,
    output:process.stdout
});
var arr=[];
rl.on('line',function(inp){
    arr.push(inp);
    var len=arr.length;
    if(len%2===1&&len!==1){
        var n=parseInt(arr[arr.length-2]),a=arr[arr.length-1].split(' ');
        for(var i=0;i<n;i++) a[i]=parseInt(a[i]);
        if(a[0]+a[1]>a[a.length-1]) console.log(-1);
        else console.log(1,2,a.length);
    }
    if(len===parseInt(arr[0])*2+1) process.exit(0);
});

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

    let [start, end] = [0, len - 1];
    let found = false;
    while (start < end) {
      const [a, b, c] = [arr[start], arr[start + 1], arr[end]];
      if (a + b <= c) {
        found = true;
        console.log(`${start + 1} ${start + 2} ${end + 1}`);
        break;
      }
      if (a + b > c) {
        found = true;
        console.log(-1);
        break;
      }
      end--;
    }

    !found && console.log(-1);
  }
}

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

    if (arr[0] + arr[1] > arr[len - 1]) {
      console.log(-1);
    } else {
      console.log(`1 2 ${len}`);
    }
  }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
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';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//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();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var list = nextIntArray();
    for(var j = 2; j < N; j++){
      if(list[0] + list[1] <= list[j]){
        output[i] = "1 2 " + (j + 1);
        break;
      }
    }
    if(output[i] == null){
      output[i] = -1;
    }
  }
  myout(myconv(output, 9));
}

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

let inputString = '';
let currentLine = 0;

const runMain = () => {
  inputString = inputString.trim().split('\n').map(string => string.trim());
  main();
  process.exit();
}
const readLine = () => inputString[currentLine++];

process.stdin.on('data', inputStdin => inputString += inputStdin);
process.stdin.on('end', runMain);
process.on('SIGINT', runMain);

function main() {
  let t = readLine();
  while (t--) {
    const n = readLine();
    const str = readLine();
    const a = str.split(' ').map(num => Number(num));
    if (a[0] + a[1] <= a[a.length - 1]) {
      console.log(1, 2, a.length);
    } else {
      console.log(-1);
    }
  }
}

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

let stdinInput = '';

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

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split('\n');
    const testCases = data[0] * 2;
    let i = 1;
    while (i <= testCases) {
        const arr = data[i + 1].trim().split(' ').map(Number);
        // const n = int[2] * 1;
        let a = arr[0];
        let b = arr[1];
        let d = arr[2];
        let c = arr[arr.length - 1];
        if (a + b <= c) console.log('1 2 '+ arr.length);
        else if (a + b <= d) console.log('1 2 3');
        else console.log('-1');
        i += 2;
    }
}

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 t = Number(readLine())
  for (let i = 0; i < t; i++) {
	const n = Number(readLine())
    const as = readLine().split(/\s/).map(Number)
    const ai = as[0], aj = as[1], ak = as[n - 1]
    if (ak >= ai + aj) {
      console.log(1, 2, n)
    } else {
      console.log(-1)
    }
  }
}

var input = "";
var chunks = [];

process.stdin.on("data", function(data) {
    input += data;
});

process.stdin.on("end", function() {
    chunks = input.split("\n");
    start();
});

function start() {
    T = parseInt(chunks.shift(), 10);
    for (let i = 0; i < T; ++i) {
        let n = parseInt(chunks.shift(), 10);
        let numbers = chunks.shift().split(" ").map(n => parseInt(n, 10));
        const triplet = run(numbers);
        if (triplet) {
            console.log(triplet.join(' '));
        } else {
            console.log(-1);
        }
    }
    process.exit(0);
}

function run(numbers) {
    let ni = numbers[0];
    let nj = numbers[1];
    let nk = numbers[numbers.length - 1];
    return ni + nj <= nk ? [1, 2, numbers.length] : false;
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var inputString = '';
var inputArray = [];
var currentLine = 0;
process.stdin.on('data', function (inputStdin) {
    inputString += inputStdin;
});
process.stdin.on('end', function (_) {
    inputArray = inputString.trim().split('\n').map(function (string) {
        return string.trim();
    });
    main();
});
function readline() {
    return inputArray[currentLine++];
}
function main() {
    var t = parseInt(readline());
    for (var i = 0; i < t; i++) {
        var n = parseInt(readline());
        var nums = readline().split(" ").map(function (x) { return parseInt(x); });
        if (nums[0] + nums[1] <= nums[n - 1]) {
            console.log(1, 2, n);
        }
        else {
            console.log(-1);
        }
    }
}

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

function readDOM() {

}

const CONFIG = {
    // getStringFunc: readDOM;
};

function factorial(n) {
    if (n < 2) return 1;
    else return n * factorial(n - 1);
}

stdioCPPattern({}, ({ readNum, readStr, writeLine }) => {
    // your code goes here
    let tc_count = readNum();

    const a = Array(1e5);
    let n;

    while (tc_count--) {
        n = readNum();
        for (let i = 0; i < n; i++) {
            a[i] = readNum();
        }

        if (a[0] + a[1] <= a[n-1]) {
            writeLine(`1 2 ${n}`);
        } else {
            writeLine(-1);
        }
    }
});

/**
 * @author flynn
 */
// WARNING!!!
// DO NOT MODIFY THE CODE BELOW
// IT WILL STOP WORKING FOREVERRRRRRRRRRR!!!
function stdinReadAll() {
    const fs = require("fs");
    return fs.readFileSync(0).toString();
}

function stdioCPPattern({
    getStringFunc = stdinReadAll
}, callbackfn) {
    const aStr = getStringFunc() + "\n";

    let cur = 0;
    const resultList = [];// Array(numberOfLine);

    callbackfn({
        log: console.log,
        readNum() {
            let x = 0, ch = aStr.charCodeAt(cur) - 48;
            while (ch < 0 || 9 < ch) ch = aStr.charCodeAt(++cur) - 48;
            while (0 <= ch && ch <= 9) {
                x = x * 10 + ch;
                ch = aStr.charCodeAt(++cur) - 48;
            }
            return x;
        },
        writeLine(data) {
            resultList.push(`${data}`);
        },
        readStr(len = 1e6) {
            const chArr = Array(len);
            let ch = aStr[cur], i = 0;
            while (ch < "a" || "z" < ch) ch = aStr[++cur];
            while ("a" <= ch && ch <= "z") {
                chArr[i++] = ch;
                ch = aStr[++cur];
            }
            return chArr.join("");
        }
    });
    let prompt = resultList.join("\n");
    if (prompt) console.log(prompt);
}

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++];
}

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function gcdArr() {
	let args = arguments;
	let res = args[0];
	let { length } = args;
	for (let i = 1; i < length; i++) {
		res = gcd(res, args[i]);
	}
	return res;
}

function main() {
	let t = readLine() >> 0;
	while (t--) {
		let n = readLine() >> 0;
		let a = readLine()
			.split(' ')
			.map(x => x >> 0);

		if (a[0] + a[1] > a[n - 1]) console.log(-1);
		else console.log(1, 2, n);
	}
}

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 => string.trim());

    main();
});

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

function main() {
    const numCases = parseInt(readLine());
    for (let c = 0; c < numCases; c++) {
        const length = parseInt(readLine());
        const array = readLine().split(" ").map(i => parseInt(i));

        if (array[0] + array[1] <= array[array.length - 1]) {
            console.log(1, 2, array.length);
        } else {
            console.log(-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++];
}

function main(){
    let t = parseInt(readline());
    for(let o = 0; o < t; o++){
        let n = parseInt(readline());
        let arr = readline().split(' ');

        if(arr.length <= 2){
            console.log(-1);
            continue;
        }

        if(parseInt(arr[0]) + parseInt(arr[1]) > parseInt(arr[n-1]))
            console.log(-1);
        else{
            console.log(1);
            console.log(2);
            console.log(n);
        }
    }
}

'use strict';

var readline = require('readline');

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */

var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return extendStatics(d, b);
};

function __extends(d, b) {
    extendStatics(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function isFunction(x) {
    return typeof x === 'function';
}

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var _enable_super_gross_mode_that_will_cause_bad_things = false;
var config = {
    Promise: undefined,
    set useDeprecatedSynchronousErrorHandling(value) {
        if (value) {
            var error = /*@__PURE__*/ new Error();
            /*@__PURE__*/ console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
        }
        _enable_super_gross_mode_that_will_cause_bad_things = value;
    },
    get useDeprecatedSynchronousErrorHandling() {
        return _enable_super_gross_mode_that_will_cause_bad_things;
    },
};

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function hostReportError(err) {
    setTimeout(function () { throw err; }, 0);
}

/** PURE_IMPORTS_START _config,_util_hostReportError PURE_IMPORTS_END */
var empty = {
    closed: true,
    next: function (value) { },
    error: function (err) {
        if (config.useDeprecatedSynchronousErrorHandling) {
            throw err;
        }
        else {
            hostReportError(err);
        }
    },
    complete: function () { }
};

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var isArray = /*@__PURE__*/ (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function isObject(x) {
    return x !== null && typeof x === 'object';
}

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var UnsubscriptionErrorImpl = /*@__PURE__*/ (function () {
    function UnsubscriptionErrorImpl(errors) {
        Error.call(this);
        this.message = errors ?
            errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n  ') : '';
        this.name = 'UnsubscriptionError';
        this.errors = errors;
        return this;
    }
    UnsubscriptionErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
    return UnsubscriptionErrorImpl;
})();
var UnsubscriptionError = UnsubscriptionErrorImpl;

/** PURE_IMPORTS_START _util_isArray,_util_isObject,_util_isFunction,_util_UnsubscriptionError PURE_IMPORTS_END */
var Subscription = /*@__PURE__*/ (function () {
    function Subscription(unsubscribe) {
        this.closed = false;
        this._parentOrParents = null;
        this._subscriptions = null;
        if (unsubscribe) {
            this._ctorUnsubscribe = true;
            this._unsubscribe = unsubscribe;
        }
    }
    Subscription.prototype.unsubscribe = function () {
        var errors;
        if (this.closed) {
            return;
        }
        var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
        this.closed = true;
        this._parentOrParents = null;
        this._subscriptions = null;
        if (_parentOrParents instanceof Subscription) {
            _parentOrParents.remove(this);
        }
        else if (_parentOrParents !== null) {
            for (var index = 0; index < _parentOrParents.length; ++index) {
                var parent_1 = _parentOrParents[index];
                parent_1.remove(this);
            }
        }
        if (isFunction(_unsubscribe)) {
            if (_ctorUnsubscribe) {
                this._unsubscribe = undefined;
            }
            try {
                _unsubscribe.call(this);
            }
            catch (e) {
                errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
            }
        }
        if (isArray(_subscriptions)) {
            var index = -1;
            var len = _subscriptions.length;
            while (++index < len) {
                var sub = _subscriptions[index];
                if (isObject(sub)) {
                    try {
                        sub.unsubscribe();
                    }
                    catch (e) {
                        errors = errors || [];
                        if (e instanceof UnsubscriptionError) {
                            errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
                        }
                        else {
                            errors.push(e);
                        }
                    }
                }
            }
        }
        if (errors) {
            throw new UnsubscriptionError(errors);
        }
    };
    Subscription.prototype.add = function (teardown) {
        var subscription = teardown;
        if (!teardown) {
            return Subscription.EMPTY;
        }
        switch (typeof teardown) {
            case 'function':
                subscription = new Subscription(teardown);
            case 'object':
                if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
                    return subscription;
                }
                else if (this.closed) {
                    subscription.unsubscribe();
                    return subscription;
                }
                else if (!(subscription instanceof Subscription)) {
                    var tmp = subscription;
                    subscription = new Subscription();
                    subscription._subscriptions = [tmp];
                }
                break;
            default: {
                throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
            }
        }
        var _parentOrParents = subscription._parentOrParents;
        if (_parentOrParents === null) {
            subscription._parentOrParents = this;
        }
        else if (_parentOrParents instanceof Subscription) {
            if (_parentOrParents === this) {
                return subscription;
            }
            subscription._parentOrParents = [_parentOrParents, this];
        }
        else if (_parentOrParents.indexOf(this) === -1) {
            _parentOrParents.push(this);
        }
        else {
            return subscription;
        }
        var subscriptions = this._subscriptions;
        if (subscriptions === null) {
            this._subscriptions = [subscription];
        }
        else {
            subscriptions.push(subscription);
        }
        return subscription;
    };
    Subscription.prototype.remove = function (subscription) {
        var subscriptions = this._subscriptions;
        if (subscriptions) {
            var subscriptionIndex = subscriptions.indexOf(subscription);
            if (subscriptionIndex !== -1) {
                subscriptions.splice(subscriptionIndex, 1);
            }
        }
    };
    Subscription.EMPTY = (function (empty) {
        empty.closed = true;
        return empty;
    }(new Subscription()));
    return Subscription;
}());
function flattenUnsubscriptionErrors(errors) {
    return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
}

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var rxSubscriber = /*@__PURE__*/ (function () {
    return typeof Symbol === 'function'
        ? /*@__PURE__*/ Symbol('rxSubscriber')
        : '@@rxSubscriber_' + /*@__PURE__*/ Math.random();
})();

/** PURE_IMPORTS_START tslib,_util_isFunction,_Observer,_Subscription,_internal_symbol_rxSubscriber,_config,_util_hostReportError PURE_IMPORTS_END */
var Subscriber = /*@__PURE__*/ (function (_super) {
    __extends(Subscriber, _super);
    function Subscriber(destinationOrNext, error, complete) {
        var _this = _super.call(this) || this;
        _this.syncErrorValue = null;
        _this.syncErrorThrown = false;
        _this.syncErrorThrowable = false;
        _this.isStopped = false;
        switch (arguments.length) {
            case 0:
                _this.destination = empty;
                break;
            case 1:
                if (!destinationOrNext) {
                    _this.destination = empty;
                    break;
                }
                if (typeof destinationOrNext === 'object') {
                    if (destinationOrNext instanceof Subscriber) {
                        _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
                        _this.destination = destinationOrNext;
                        destinationOrNext.add(_this);
                    }
                    else {
                        _this.syncErrorThrowable = true;
                        _this.destination = new SafeSubscriber(_this, destinationOrNext);
                    }
                    break;
                }
            default:
                _this.syncErrorThrowable = true;
                _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
                break;
        }
        return _this;
    }
    Subscriber.prototype[rxSubscriber] = function () { return this; };
    Subscriber.create = function (next, error, complete) {
        var subscriber = new Subscriber(next, error, complete);
        subscriber.syncErrorThrowable = false;
        return subscriber;
    };
    Subscriber.prototype.next = function (value) {
        if (!this.isStopped) {
            this._next(value);
        }
    };
    Subscriber.prototype.error = function (err) {
        if (!this.isStopped) {
            this.isStopped = true;
            this._error(err);
        }
    };
    Subscriber.prototype.complete = function () {
        if (!this.isStopped) {
            this.isStopped = true;
            this._complete();
        }
    };
    Subscriber.prototype.unsubscribe = function () {
        if (this.closed) {
            return;
        }
        this.isStopped = true;
        _super.prototype.unsubscribe.call(this);
    };
    Subscriber.prototype._next = function (value) {
        this.destination.next(value);
    };
    Subscriber.prototype._error = function (err) {
        this.destination.error(err);
        this.unsubscribe();
    };
    Subscriber.prototype._complete = function () {
        this.destination.complete();
        this.unsubscribe();
    };
    Subscriber.prototype._unsubscribeAndRecycle = function () {
        var _parentOrParents = this._parentOrParents;
        this._parentOrParents = null;
        this.unsubscribe();
        this.closed = false;
        this.isStopped = false;
        this._parentOrParents = _parentOrParents;
        return this;
    };
    return Subscriber;
}(Subscription));
var SafeSubscriber = /*@__PURE__*/ (function (_super) {
    __extends(SafeSubscriber, _super);
    function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
        var _this = _super.call(this) || this;
        _this._parentSubscriber = _parentSubscriber;
        var next;
        var context = _this;
        if (isFunction(observerOrNext)) {
            next = observerOrNext;
        }
        else if (observerOrNext) {
            next = observerOrNext.next;
            error = observerOrNext.error;
            complete = observerOrNext.complete;
            if (observerOrNext !== empty) {
                context = Object.create(observerOrNext);
                if (isFunction(context.unsubscribe)) {
                    _this.add(context.unsubscribe.bind(context));
                }
                context.unsubscribe = _this.unsubscribe.bind(_this);
            }
        }
        _this._context = context;
        _this._next = next;
        _this._error = error;
        _this._complete = complete;
        return _this;
    }
    SafeSubscriber.prototype.next = function (value) {
        if (!this.isStopped && this._next) {
            var _parentSubscriber = this._parentSubscriber;
            if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                this.__tryOrUnsub(this._next, value);
            }
            else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
                this.unsubscribe();
            }
        }
    };
    SafeSubscriber.prototype.error = function (err) {
        if (!this.isStopped) {
            var _parentSubscriber = this._parentSubscriber;
            var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
            if (this._error) {
                if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                    this.__tryOrUnsub(this._error, err);
                    this.unsubscribe();
                }
                else {
                    this.__tryOrSetError(_parentSubscriber, this._error, err);
                    this.unsubscribe();
                }
            }
            else if (!_parentSubscriber.syncErrorThrowable) {
                this.unsubscribe();
                if (useDeprecatedSynchronousErrorHandling) {
                    throw err;
                }
                hostReportError(err);
            }
            else {
                if (useDeprecatedSynchronousErrorHandling) {
                    _parentSubscriber.syncErrorValue = err;
                    _parentSubscriber.syncErrorThrown = true;
                }
                else {
                    hostReportError(err);
                }
                this.unsubscribe();
            }
        }
    };
    SafeSubscriber.prototype.complete = function () {
        var _this = this;
        if (!this.isStopped) {
            var _parentSubscriber = this._parentSubscriber;
            if (this._complete) {
                var wrappedComplete = function () { return _this._complete.call(_this._context); };
                if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
                    this.__tryOrUnsub(wrappedComplete);
                    this.unsubscribe();
                }
                else {
                    this.__tryOrSetError(_parentSubscriber, wrappedComplete);
                    this.unsubscribe();
                }
            }
            else {
                this.unsubscribe();
            }
        }
    };
    SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
        try {
            fn.call(this._context, value);
        }
        catch (err) {
            this.unsubscribe();
            if (config.useDeprecatedSynchronousErrorHandling) {
                throw err;
            }
            else {
                hostReportError(err);
            }
        }
    };
    SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
        if (!config.useDeprecatedSynchronousErrorHandling) {
            throw new Error('bad call');
        }
        try {
            fn.call(this._context, value);
        }
        catch (err) {
            if (config.useDeprecatedSynchronousErrorHandling) {
                parent.syncErrorValue = err;
                parent.syncErrorThrown = true;
                return true;
            }
            else {
                hostReportError(err);
                return true;
            }
        }
        return false;
    };
    SafeSubscriber.prototype._unsubscribe = function () {
        var _parentSubscriber = this._parentSubscriber;
        this._context = null;
        this._parentSubscriber = null;
        _parentSubscriber.unsubscribe();
    };
    return SafeSubscriber;
}(Subscriber));

/** PURE_IMPORTS_START _Subscriber PURE_IMPORTS_END */
function canReportError(observer) {
    while (observer) {
        var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
        if (closed_1 || isStopped) {
            return false;
        }
        else if (destination && destination instanceof Subscriber) {
            observer = destination;
        }
        else {
            observer = null;
        }
    }
    return true;
}

/** PURE_IMPORTS_START _Subscriber,_symbol_rxSubscriber,_Observer PURE_IMPORTS_END */
function toSubscriber(nextOrObserver, error, complete) {
    if (nextOrObserver) {
        if (nextOrObserver instanceof Subscriber) {
            return nextOrObserver;
        }
        if (nextOrObserver[rxSubscriber]) {
            return nextOrObserver[rxSubscriber]();
        }
    }
    if (!nextOrObserver && !error && !complete) {
        return new Subscriber(empty);
    }
    return new Subscriber(nextOrObserver, error, complete);
}

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
var observable = /*@__PURE__*/ (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();

/** PURE_IMPORTS_START  PURE_IMPORTS_END */
function identity(x) {
    return x;
}

/** PURE_IMPORTS_START _identity PURE_IMPORTS_END */
function pipeFromArray(fns) {
    if (fns.length === 0) {
        return identity;
    }
    if (fns.length === 1) {
        return fns[0];
    }
    return function piped(input) {
        return fns.reduce(function (prev, fn) { return fn(prev); }, input);
    };
}

/** PURE_IMPORTS_START _util_canReportError,_util_toSubscriber,_symbol_observable,_util_pipe,_config PURE_IMPORTS_END */
var Observable = /*@__PURE__*/ (function () {
    function Observable(subscribe) {
        this._isScalar = false;
        if (subscribe) {
            this._subscribe = subscribe;
        }
    }
    Observable.prototype.lift = function (operator) {
        var observable = new Observable();
        observable.source = this;
        observable.operator = operator;
        return observable;
    };
    Observable.prototype.subscribe = function (observerOrNext, error, complete) {
        var operator = this.operator;
        var sink = toSubscriber(observerOrNext, error, complete);
        if (operator) {
            sink.add(operator.call(sink, this.source));
        }
        else {
            sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
                this._subscribe(sink) :
                this._trySubscribe(sink));
        }
        if (config.useDeprecatedSynchronousErrorHandling) {
            if (sink.syncErrorThrowable) {
                sink.syncErrorThrowable = false;
                if (sink.syncErrorThrown) {
                    throw sink.syncErrorValue;
                }
            }
        }
        return sink;
    };
    Observable.prototype._trySubscribe = function (sink) {
        try {
            return this._subscribe(sink);
        }
        catch (err) {
            if (config.useDeprecatedSynchronousErrorHandling) {
                sink.syncErrorThrown = true;
                sink.syncErrorValue = err;
            }
            if (canReportError(sink)) {
                sink.error(err);
            }
            else {
                console.warn(err);
            }
        }
    };
    Observable.prototype.forEach = function (next, promiseCtor) {
        var _this = this;
        promiseCtor = getPromiseCtor(promiseCtor);
        return new promiseCtor(function (resolve, reject) {
            var subscription;
            subscription = _this.subscribe(function (value) {
                try {
                    next(value);
                }
                catch (err) {
                    reject(err);
                    if (subscription) {
                        subscription.unsubscribe();
                    }
                }
            }, reject, resolve);
        });
    };
    Observable.prototype._subscribe = function (subscriber) {
        var source = this.source;
        return source && source.subscribe(subscriber);
    };
    Observable.prototype[observable] = function () {
        return this;
    };
    Observable.prototype.pipe = function () {
        var operations = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            operations[_i] = arguments[_i];
        }
        if (operations.length === 0) {
            return this;
        }
        return pipeFromArray(operations)(this);
    };
    Observable.prototype.toPromise = function (promiseCtor) {
        var _this = this;
        promiseCtor = getPromiseCtor(promiseCtor);
        return new promiseCtor(function (resolve, reject) {
            var value;
            _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
        });
    };
    Observable.create = function (subscribe) {
        return new Observable(subscribe);
    };
    return Observable;
}());
function getPromiseCtor(promiseCtor) {
    if (!promiseCtor) {
        promiseCtor =  Promise;
    }
    if (!promiseCtor) {
        throw new Error('no Promise impl found');
    }
    return promiseCtor;
}

function tnLineStdinReader() {
  return new Observable(function (subscribe) {
    var stdin = readline.createInterface(process.stdin);
    var tests = null;
    var n = null;
    stdin.on('line', function (line) {
      if (tests === null) {
        tests = +line;
      } else if (n === null) {
        n = +line;
        tests--;
      } else {
        n = null;
        subscribe.next(line);

        if (tests === 0) {
          stdin.close();
          subscribe.complete();
        }
      }
    });
  });
}

tnLineStdinReader().subscribe(function (line) {
  var numbers = line.split(' ').map(Number);

  if (numbers[0] + numbers[1] <= numbers[numbers.length - 1]) {
    console.log("1 2 ".concat(numbers.length));
  } else {
    console.log('-1');
  }
});

var t = parseInt(readline());
n = [];
sides = [];
for (var i = 0; i < t; i++) {
  n.push(parseInt(readline()));
  sides.push(readline().split(' ').map(x => parseInt(x)));
}
for (var i = 0; i < t; i++){
  found = 0;
  if (sides[i][0] + sides[i][1] <= sides[i][n[i]-1]) {
    print(1, 2, n[i]);
    found = 1;
  }
  if (found == 0) {
    print(-1);
  }
}

var readline=require('readline');
var rl=readline.createInterface({
    input:process.stdin,
    output:process.stdout
});
var arr=[];
rl.on('line',function(inp){
    arr.push(inp);
    var len=arr.length;
    if(len%2===1&&len!=1){
        var n=parseInt(arr[arr.length-2]),a=arr[arr.length-1].split(' ');
        for(var i=0;i<n;i++) a[i]=parseInt(a[i]);
        if(a[0]+a[1]>=a[a.length-1]) console.log(-1);
        else console.log(1,2,a.length);
    }
    if(len===parseInt(arr[0])*2+1) process.exit(0);
});

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

    let [start, mid, end] = [0, 0, 0];
    let found = false;
    for (let i = 0; i < len - 2; i++) {
      const [a, b, c] = [arr[0], arr[i + 1], arr[i + 2]];
      if (!(a + b > c)) {
        start = 1;
        mid = i + 2;
        end = i + 3;
        console.log(`${start} ${mid} ${end}`);
        found = true;
        break;
      }
    }
    !found && console.log(-1);
  }
}

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

    let [start, end] = [0, len - 1];
    let found = false;
    while (start < end - 1) {
      const [a, b, c] = [arr[start], arr[end - 1], arr[end]];
      if (c - a > b) {
        found = true;
        console.log(`${start + 1} ${end} ${end + 1}`);
        break;
      }
      end--;
    }
    !found && console.log(-1);
  }
}

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

    let [start, end] = [0, 0];
    let found = false;
    for (let i = 0; i < len - 2; i++) {
      const [a, b, c] = [arr[i], arr[i + 1], arr[i + 2]];
      if (!(a + b > c)) {
        start = i + 1;
        end = i + 3;
        console.log(`${start} ${start + 1} ${start + 2}`);
        found = true;
        break;
      }
    }
    !found && console.log(-1);
  }
}

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

    let [start, end] = [0, 0];

    for (let i = 0; i < len - 2; i++) {
      if (arr[i] + arr[i + 1] <= arr[i + 2]) {
        start = i + 1;
        end = i + 3;
        break;
      }
    }
    if (start === 0 && end === 0) {
      console.log(-1);
    } else {
      console.log(`${start} ${start + 1} ${start + 2}`);
    }
  }
}

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

    let [start, end] = [0, len - 1];
    let found = false;
    while (start < end - 1) {
      const [a, b, c] = [arr[start], arr[end - 1], arr[end]];
      if (c - a > b) {
        found = true;
        console.log(`${start + 1} ${end} ${end + 1}`);
        break;
      }
      end--;
    }
    if (!found) {
      while (start < end - 1) {
        const [a, b, c] = [arr[start], arr[end - 1], arr[end]];
        if (c - a > b) {
          found = true;
          console.log(`${start + 1} ${end} ${end + 1}`);
          break;
        }
        start++;
      }
    }
    if (!found) {
      while (start < end - 1) {
        const [a, b, c] = [arr[start], arr[end - 1], arr[end]];
        if (c - a > b) {
          found = true;
          console.log(`${start + 1} ${end} ${end + 1}`);
          break;
        }
        start++;
        end--;
      }
    }
    !found && console.log(-1);
  }
}

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

    let [start, end] = [0, 0];

    for (let i = 0; i < len - 2; i++) {
      if (arr[i + 1] - arr[i] > 1 || arr[i + 2] - arr[i + 1] > 1) {
        start = i + 1;
        end = i + 3;
        break;
      }
    }
    if (start === 0 && end === 0) {
      console.log(-1);
    } else {
      console.log(`${start} ${start + 1} ${start + 2}`);
    }
  }
}

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

    let [start, end] = [0, 0];
    let found = false;
    for (let i = 0; i < len - 2; i++) {
      const [a, b, c] = [arr[i], arr[i + 1], arr[i + 2]];
      if (!(a + b > c && a + c > b && b + c > a)) {
        start = i + 1;
        end = i + 3;
        console.log(`${start} ${start + 1} ${start + 2}`);
        found = true;
        break;
      }
    }
    !found && console.log(-1);
  }
}

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

let inputString = '';
let currentLine = 0;

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

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

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

function main() {
  let t = readLine();
  while (t--) {
    const n = readLine();
    const str = readLine();
    const a = str.split(' ').map(num => Number(num));
    if (a[0] + a[1] <= a[a.length - 1]) {
      console.log(a[0], a[1], a[a.length - 1]);
    } else {
      console.log(-1);
    }
  }
}

var input = "";
var chunks = [];

process.stdin.on("data", function(data) {
    input += data;
});

process.stdin.on("end", function() {
    chunks = input.split("\n");
    start();
});

function start() {
    T = parseInt(chunks.shift(), 10);
    for (let i = 0; i < T; ++i) {
        let n = parseInt(chunks.shift(), 10);
        let numbers = chunks.shift().split(" ").map(n => parseInt(n, 10));
        const triplet = run(numbers);
        if (triplet) {
            console.log(triplet.join(' '));
        } else {
            console.log(-1);
        }
    }
    process.exit(0);
}

function run(numbers) {
    let ni = numbers[0];
    let nj = numbers[1];
    let nk = numbers[numbers.length - 1];
    return ni + nj < nk ? [1, 2, numbers.length] : false;
}

var input = "";
var chunks = [];

process.stdin.on("data", function(data) {
    input += data;
});

process.stdin.on("end", function() {
    chunks = input.split("\n");
    start();
});

function start() {
    T = parseInt(chunks.shift(), 10);
    for (let i = 0; i < T; ++i) {
        let n = parseInt(chunks.shift(), 10);
        let numbers = chunks.shift().split(" ").map(n => parseInt(n, 10));
        const triplet = run(numbers);
        if (triplet) {
            console.log(triplet.join(' '));
        } else {
            console.log(-1);
        }
    }
    process.exit(0);
}

function run(numbers) {
    let ni = numbers[0];
    let nj = numbers[1];
    let nk = numbers[numbers.length - 1];
    return ni + nj < nk ? [0, 1, numbers.length - 1] : false;
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
var inputString = '';
var inputArray = [];
var currentLine = 0;
process.stdin.on('data', function (inputStdin) {
    inputString += inputStdin;
});
process.stdin.on('end', function (_) {
    inputArray = inputString.trim().split('\n').map(function (string) {
        return string.trim();
    });
    main();
});
function readline() {
    return inputArray[currentLine++];
}
function main() {
    var t = parseInt(readline());
    for (var i = 0; i < t; i++) {
        var n = parseInt(readline());
        var nums = readline().split(" ").map(function (x) { return parseInt(x); });
        if (nums[0] + nums[1] <= nums[n - 1]) {
            console.log(0, 1, n - 1);
        }
        else {
            console.log(-1);
        }
    }
}

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++];
}

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function gcdArr() {
	let args = arguments;
	let res = args[0];
	let { length } = args;
	for (let i = 1; i < length; i++) {
		res = gcd(res, args[i]);
	}
	return res;
}

function main() {
	let t = readLine() >> 0;
	while (t--) {
		let n = readLine() >> 0;
		let a = readLine()
			.split(' ')
			.map(x => x >> 0);

		if (a[0] + a[1] >= a[n - 1]) console.log(-1);
		else console.log(1, 2, n);
	}
}

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++];
}

var dp = {};

function fibonacci(n) {
	if (n === 0) return 0;
	if (n === 1) return 1;

	if (dp[n] !== undefined) return dp[n];
	let result = fibonacci(n - 1) + fibonacci(n - 2);
	return (dp[n] = result);
}

function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function gcdArr() {
	let args = arguments;
	let res = args[0];
	let { length } = args;
	for (let i = 1; i < length; i++) {
		res = gcd(res, args[i]);
	}
	return res;
}

function main() {
	let t = readLine() >> 0;
	while (t--) {
		let n = readLine() >> 0;
		let a = readLine()
			.split(' ')
			.map(x => x >> 0);

		let pos = [],
			flag = false;
		for (let i = 0; i < n - 2; i++) {
			if (a[i] + a[i + 1] <= a[i + 2]) {
				flag = true;
				pos.push(i + 1, i + 2, i + 3);
				break;
			}
		}

		flag ? console.log(pos.join(' ')) : console.log(-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 => string.trim());

    main();
});

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

function main() {
    const numCases = parseInt(readLine());
    for (let c = 0; c < numCases; c++) {
        const length = parseInt(readLine());
        const array = readLine().split(" ").map(i => parseInt(i));

        if (array[0] + array[1] <= array[array.length - 1]) {
            console.log(1, 1, array.length - 1);
        } else {
            console.log(-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 => string.trim());

    main();
});

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

function main() {
    const numCases = parseInt(readLine());
    for (let c = 0; c < numCases; c++) {
        const length = parseInt(readLine());
        const array = readLine().split(" ").map(i => parseInt(i));

        if (array[0] + array[1] <= array[array.length - 1]) {
            console.log(array[0], array[1], array[array.length - 1]);
        } else {
            console.log(-1);
        }
    }
}


Casimir has a string $$$s$$$ which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions:  he can either erase exactly one letter 'A' and exactly one letter 'B' from arbitrary places of the string (these letters don't have to be adjacent);  or he can erase exactly one letter 'B' and exactly one letter 'C' from arbitrary places in the string (these letters don't have to be adjacent). Therefore, each turn the length of the string is decreased exactly by $$$2$$$. All turns are independent so for each turn, Casimir can choose any of two possible actions.For example, with $$$s$$$ $$$=$$$ "ABCABC" he can obtain a string $$$s$$$ $$$=$$$ "ACBC" in one turn (by erasing the first occurrence of 'B' and the second occurrence of 'A'). There are also many other options for a turn aside from this particular example.For a given string $$$s$$$ determine whether there is a sequence of actions leading to an empty string. In other words, Casimir's goal is to erase all letters from the string. Is there a way to do this?

The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case is described by one string $$$s$$$, for which you need to determine if it can be fully erased by some sequence of turns. The string $$$s$$$ consists of capital letters 'A', 'B', 'C' and has a length from $$$1$$$ to $$$50$$$ letters, inclusive.

Print $$$t$$$ lines, each line containing the answer to the corresponding test case. The answer to a test case should be YES if there is a way to fully erase the corresponding string and NO otherwise. You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answers).

6
ABACAB
ABBA
AC
ABC
CABCBB
BCBCBCBCBCBCBCBC

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var s = 0
    for(j = 1; j <= lines[0]; j++){
        var a = 0
        var b = 0
        var c = 0
        var l = lines[j].split('')
        for(k = 0; k < l.length; k++){
            if(l[k] == 'A'){
                a++
            }else if(l[k] == 'B'){
                b++
            }else if(l[k] == 'C'){
                c++
            }
        }
        if(a + c == 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 d = 1; d <= n; d++){
    var a = 0;
    var b = 0;
    var c = 0;
        var k = lines[d].split('');
        for(var j = 0; j < k.length; j++){
            if(k[j] == 'A'){
                a += 1;
            }else if(k[j] == 'B'){
                b += 1;
            }else if(k[j] == 'C'){
                c += 1;
            }
        }
        if(a + c == 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++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const t = Number(readline());
    for(let i = 0; i < t; i++) {
        const str = readline();
        const countArr = count(str);
        const A = countArr[0], B = countArr[1], C = countArr[2];
        console.log(check(A, B, C));

    }
}

function count(str) {
    let A = 0, B = 0, C = 0;
    for(const char of str) {
        if(char == "A") A++;
        if(char == "B") B++;
        if(char == "C") C++;
    }
    return [A, B, C];
}

function check(A, B, C) {
    if(A <= B) B = B - A;
    else return "NO";
    if(B == C) return "YES"
    else return "NO";
}

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

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let a = [...(nl.line())];
		let acc = a.reduce((ac, e) => {
			ac[e]++;
			return ac;
			}, {'A':0, 'B': 0, 'C': 0});
		ans.push(acc['A'] + acc['C'] === acc['B']);
	}
	console.log(ans.map(e => e?"YES":"NO").join('\n'));

};

process.stdin.on('end', sol);

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

let c = 0;

rl.on("line", (str) => {
  if (c === 0) {
    c++;
    return;
  }

  let ac = 0;
  let b = 0;

  for (let i = 0; i < str.length; i++) {
    if (str[i] === "B") {
      b++;
    } else {
      ac++;
    }
  }

  if (ac === b) {
    console.log("YES");
  } else {
    console.log("NO");
  }

  c++;
});

rl.on("close", () => {});

'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 ans(){
    let s = readLine();
    let a = 0;
    let b = 0;
    let c = 0;
    for(let i = 0; i < s.length; i++){
        if(s[i] == 'A') a++;
        else if(s[i] == 'B') b++;
        else c++;
    }
    let res = ((a + c == b) ? "YES" : "NO");
    return res;
}

function main(){
    let t = readLine();
    while(t--){
        console.log(ans());
        console.log('\n');
    }
}

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 s = rl();

		let acnt = 0, bcnt = 0, ccnt = 0;
		for (const c of s) {
			acnt += c == 'A';
			bcnt += c == 'B';
			ccnt += c == 'C';
		}

		console.log(acnt + ccnt == bcnt ? 'YES' : '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];
    var a = 0;
    var b = 0;
    var c = 0;
    for(var d = 1; d <= n; d++){
        a = 0;
        b = 0;
        c = 0;
        var k = lines[d].split('');
        for(var j = 0; j < k.length; j++){
            if(k[j] == 'A'){
                a += 1;
            }else if(k[j] == 'B'){
                b += 1;
            }else if(k[j] == 'C'){
                c += 1;
            }
        }
        if(a + c == b){
            console.log('YES');
        }else{
            console.log('NO');
        }
    }
});

/*
** 1579 A Casimir's String Solitaire
*/

// Common Template Starts //
//*
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++];
}
// Common Template Ends //

// LIBRARY START //

const isOdd = (x) => { return x & 1 }
const isEven = (x) => { return !(x & 1) }

const reverseText = (s) => { return s.split('').reverse().join('') }
const hasDuplicates = (str) => (/([a-z])\1/i).test(str)

const hasDuplicateChar = (str, char) => str.indexOf(char) !== str.lastIndexOf(char)

const isSorted = arr => arr.every((v, i, a) => !i || a[i - 1] <= v);

const findAllIndicesOfChar = (str, char) => {
    str = str.split('')
    let indices = [];
    for (let i = 0; i < str.length; i++) {
        if (str[i] === char) indices.push(i);
    }
    return indices
}

const splitAt = index => x => [x.slice(0, index), x.slice(index)]

const isUpper = str => !/[a-z]/.test(str) && /[A-Z]/.test(str)

const escapeRegExp = (string) => string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&')

const replaceAll = (str, find, replace) => str.replace(new RegExp(escapeRegExp(find), 'g'), replace)

const findUnique = (str) => {
    return [...str].reduce((acc, curr) => {
        return acc.includes(curr) ? acc : acc + curr;
    }, "")
}

// LIBRARY END

const decode = (text) => {
    text = text.split('')
    count_a = text.filter( c => c.includes('A') ).length
    count_b = text.filter( c => c.includes('B') ).length
    count_c = text.filter( c => c.includes('C') ).length

    // if(count_b == 0) return false

    // if(count_c == 0) {
    //     if( isEven(count_a) && isEven(count_b) ) return true
    //     else return false
    // }

    // if(count_a == 0){
    //     if( isEven(count_c) && isEven(count_b) ) return true
    //     return false
    // }

    if( count_a + count_c == count_b ) return true

    return false
}

function main() {
    let cases = readline()
    while( cases-- ) {
        let txt = readline()
        decode(txt) ? console.log('YES') : console.log('NO')
    }
}
//*/

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input = '';
process.stdin.on('data', inputStdin => {
    input += inputStdin;
});
process.stdin.on('end', _ => {
    main(input);
});

function main(input) {
    var args = input.split("\n");
    const t = parseInt(args[0], 10);
    for (var i = 1; i <= t; i++) {
        var arg = args[i].split("");
        var a = arg.filter(function (x) { return x == 'A' }).length;
        var b = arg.filter(function (x) { return x == 'B' }).length;
        var c = arg.filter(function (x) { return x == 'C' }).length;
        if (a + c == b) {
            console.log("YES");
        } else {
            console.log("NO");
        }
    }
}

'use strict';

const fs = require('fs');

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', function () {
    inputString = inputString.split('\n');
    main();
});

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

function problemSolving(str) {
    let a=0, b=0, c = 0;
    for (let i = 0; i < str.length; i++) {
        if (str[i] == 'A')
            a++;
        else if (str[i] == 'B')
            b++;
        else
            c++;
    }
    c--;
    if (a + c == b)
        console.log("YES");
    else
        console.log("NO");
}

function main() {

    let t = parseInt(readLine().trim(), 10);
    while (t-- > 0) {
        const str = readLine();
        problemSolving(str);
    }
}

let i = ''
let lines
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  lines = i.split('\n')
  main()
})

function main() {
  let t = parseInt(lines.shift())

  while (t > 0) {
    let s = lines.shift()
    let ac = (s.match(/[ACac]/g) || []).length
    let b = (s.match(/[Bb]/g) || []).length
    console.log(ac == b ? 'YES' : 'NO')
    t--
  }
}

'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++];
}

const main = () => {

  let ansArr = []
  const a = readline();
  for (let i = 0; i < a; i++) {
    let str = readline();
    let abc = {A: 0, B: 0, C: 0}
    for (let j = 0; j < str.length; j++) {
      abc[str[j]]++;
    }
    if (abc['A'] + abc['C'] === abc['B']) {
      ansArr.push('YES')
    } else {
      ansArr.push('NO')
    }
  }
  process.stdout.write(ansArr.join('\n'))

}

'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++];
}
// Make a Snippet for the code above this and then write your logic in main();

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

	for(let i = 0; i < len; i++){
		let s = readline();
		println(func(s));
	}

}

function func(s){
	if(s.length % 2 != 0) return "no";

	let m = new Map();
	for(let i = 0; i < s.length; i++){
		if(m.has(s[i])){
			m.set(s[i], m.get(s[i])+1);
		}else{
			m.set(s[i], 1);
		}
	}

	let a = 0, b = 0, c = 0;
	if(m.has("A")){
		a = m.get("A");
	}
	if(m.has("B")){
		b = m.get("B");
	}
	if(m.has("C")){
		c = m.get("C");
	}

	if(b == a+c){
		return "yes";
	}
	return "no";

}

function print(x) {
    process.stdout.write(x);   // without auto '\n' (newline)
}
function println(x) {
    console.log(x);  // with auto '\n' (newline)
}

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) {
        main()
        process.exit(0)
    }
})

function solve(str) {
    const aCount = str.split('').filter(i => i === 'A').length
    const bCount = str.split('').filter(i => i === 'B').length
    const cCount = str.split('').filter(i => i === 'C').length

    if (bCount === aCount + cCount) {
        console.log('YES')
    } else {
        console.log('NO')
    }
}

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

//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] = BigInt(next());
		}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 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 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 S = next();
		var map = {A:0,B:0,C:0};
		for(var i = 0; i < S.length; i++){
			map[S[i]]++;
		}
		if(map["B"] == map["A"] + map["C"]){
			myout("YES");
		}else{
			myout("NO");
		}
	}
}

var t = readline();
var a;
for(var z=0;z<t;z++)
{
    a = readline();
    var cnt1=0, cnt2=0, cnt3=0;
    for(var i=0; i<a.length; i++)
    {
        if(a[i]=='A') cnt1++;
        else if(a[i]=='B') cnt2++;
        else cnt3++;
    }
    if(cnt2==cnt1+cnt3) print("YES");
    else print("NO");
}

var problems = parseInt(readline());

for (var i = 0; i < problems; i++) {
    var line = readline();

    var a = 0;
    var b = 0;
    var c = 0;

    for (var j = 0; j < line.length; j++) {
        if (line.charAt(j) === 'A') {
            a++;
        }
        if (line.charAt(j) === 'B') {
            b++;
        }
        if (line.charAt(j) === 'C') {
            c++;
        }
    }

    print(a + c === b ? "YES" : "NO")
}

var n = parseInt(readline());
for(var i = 0; i < n; i++){
    var arr = readline().split('')
    var dir = {A: 0, B:0, C:0};

    for (var j = 0; j < arr.length; j++){
        dir[arr[j]] ++;
    }

    print(dir['A'] + dir['C'] === dir['B'] ? 'YES': 'NO')
}

var t = +readline()
for(var i = 0; i< t; i ++) {
    var a = readline()
    var answer = canAllRemove(a)
    print(answer)
}

function canAllRemove(str){

    while(true){

        if(!str.length){
            return 'YES'
        }
        var test1 = str.indexOf('A');
        var test2 = str.indexOf('B');
        var test3 = str.indexOf('C');

        if(test1 != -1 && test2 != -1){
            str = str.replace('A','');
            str = str.replace('B','')
        }else if (test2 != -1 && test3 != -1){
            str = str.replace('B','');
            str = str.replace('C','')
        }else {
            return 'NO'
        }

    }

    // var obj = {};

    // for(let i = 0; i<str.length; i++){
    //     if(obj.hasOwnProperty(str[i])) {
    //         obj[str[i]]++;
    //     }else {
    //         obj[str[i]] = 1;
    //     }
    // }

    // if(str.indexOf('C') !== -1){
    //     return  obj['A'] + obj['C'] == obj['B'] ? 'YES' : 'NO'
    // }else {
    //     return obj['A'] == obj['B'] ? 'YES' : 'NO'
    // }
}

var lines = Number(readline());

for (var i = 0; i < lines; i++) {
    var str = readline();
    var numA = 0;
    var numB = 0;
    var numC = 0;

    for (var n = 0; n < str.length; n++) {
        if (str.charAt(n) == "A") {
            numA++;
        }
        else if (str.charAt(n) == "B") {
            numB++;
        }
        else {
            numC++;
        }

    }

    if (numB == numA + numC){
        print("YES");
    }
    else {
        print("NO");
    }

}

function main() {
    var length = readline();
    for (var i = 0; i < length; ++i) {
        var str = readline();
        var str_length = str.length;
        var b_counter = 0;
        var ac_counter = 0;
        for (var j = 0; j < str_length; j++) {
            str[j] == 'B' ? b_counter++ : ac_counter++;
        }
        b_counter == ac_counter ? print('YES') : print('NO');
    }
}

main();

n = readline();
while (n--) {
  s=readline().toString().split("");
  a = s.filter(e=>e=="A");
  b = s.filter(u=>u=="B");
  c = s.filter(k=>k=="C");
  print(a.length+c.length==b.length?"YES":"NO");
}

function main() {
var t = readline();
for (var i = 0; i < t; i++) {
  var s = readline();
var a = 0;
var b = 0;
var c = 0;
get(s)
}
function get(s) {
for (var j = 0; j < s.length; j++) {
  if (s[j] == "A") {
    a++;
  } else if (s[j] == "B") {
    b++;
  } else if (s[j] == "C") {
    c++;
  }
}
if (b === 0) {
  print("NO");
  return;
}
if (a > b || c > b) {
  print("NO");
  return;
}
if (a + c == b) {
  print("YES");
} else {
  print("NO");
}
}

}
main()

	function readStringArray() {
		return readline().split(' ');
	}
	function readNumArray() {
		return readStringArray().map(Number);
	}

	function main() {
		var testCasesNum = +readline();
		for (var i = 0; i < testCasesNum; i++) {
			var s = readline();
			var ac = 0;
			var b = 0;
			for (var j = 0; j < s.length; j++) {
				if (s[j] === 'B') {
					b++;
				} else {
					ac++;
				}
			}
			print(b === ac ? 'YES' : 'NO');
		}
	}

	main();

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var s = 0
    for(j = 1; j <= lines[0]; j++){
        var a = 0
        var b = 0
        var c = 0
        var l = lines[j].split('')
        for(k = 0; k < l.length; l++){
            if(l[k] == 'A'){
                a++
            }else if(l[k] == 'B'){
                b++
            }else if(l[k] == 'C'){
                c++
            }
        }
        if(a + c >= b){
            console.log('YES')
        }else {
            console.log('NO')
        }
    }

});

var t = readline();
var a;
for(var z=0;z<t;z++)
{
    a = readline();
    var cnt1=0, cnt2=0, cnt3=0;
    for(var i=0; i<a.length; i++)
    {
        if(a[i]=='A') cnt1++;
        else if(a[i]=='B') cnt2++;
        else cnt3++;
    }
    if(cnt2==cnt1+cnt3 && cnt2>1) print("YES");
    else print("NO");
}

var t = readline();
var a;
for(var z=0;z<t;z++)
{
    a = readline();
    var cnt1=0, cnt2=0, cnt3=0;
    for(var i=0; i<a.length; i++)
    {
        if(a[i]=='A') cnt1++;
        else if(a[i]=='B') cnt2++;
        else cnt3++;
    }
    print(a);
    print(cnt1);
    print(cnt2);
    print(cnt3);
    if(cnt2==cnt1+cnt3 && cnt2>1) print("YES");
    else print("NO");
}

var t = readline();
var a;
for(var z=0;z<t;z++)
{
    a = readline().split(' ');
    var cnt1=0, cnt2=0, cnt3=0;
    for(var i=0;i<a.length;i++)
    {
        if(a[i]=='A') cnt1++;
        else if(a[i]=='B') cnt2++;
        else cnt3++;
    }
    print(a);
    print(cnt1);
    print(cnt2);
    print(cnt3);
    if(cnt2==cnt1+cnt3 && cnt2>1) print("YES");
    else print("NO");
}

var t = readline();
var a;
for(var z=0;z<t;z++)
{
    a = readline().split(' ');
    var cnt1=0, cnt2=0, cnt3=0;
    for(var i=0;i<a.length;i++)
    {
        if(a[i]=='A') cnt1++;
        else if(a[i]=='B') cnt2++;
        else cnt3++;
    }
    print(a);
    if(cnt2==cnt1+cnt3 && cnt2>1) print("YES");
    else print("NO");
}

var t = readline();
var a;
for(var z=0;z<t;z++)
{
    a = readline().split(' ');
    var cnt1=0, cnt2=0, cnt3=0;
    for(var i=0;i<a.length;i++)
    {
        if(a[i]=='A') cnt1++;
        else if(a[i]=='B') cnt2++;
        else cnt3++;
    }
    if(cnt2==cnt1+cnt3 && cnt2>1) print("YES");
    else print("NO");
}

var t = readline();
for(var z=0;z<t;z++)
{
var a = readline().split(' ');
var cnt1=0, cnt2=0, cnt3=0;
for(var i=0;i<a.length;i++)
{
    if(a[i]=='A') cnt1++;
    else if(a[i]=='B') cnt2++;
    else cnt3++;
}
if(cnt2==cnt1+cnt3 && cnt2>1) print("YES");
else print("NO");
}

var t = readline();
for(var z=0;z<t;z++)
{
var a = readline().split(' ');
var cnt1=0, cnt2=0, cnt3=0;
for(var i=0;i<a.length;i++)
{
    if(a[i]=='A') cnt1++;
    else if(a[i]=='B') cnt2++;
    else cnt3++;
}
if(cnt2==cnt1+cnt3 && cnt2>1) print("YES\n");
else print("NO\n");
}

const problems = parseInt(readline());

for (var i = 0; i < problems; i++) {
    const line = readline();

    var a = 0;
    var b = 0;
    var c = 0;

    for (var j = 0; j < line.length; j++) {
        if (line.charAt(j) === 'A') {
            a++;
        }
        if (line.charAt(j) === 'B') {
            b++;
        }
        if (line.charAt(j) === 'C') {
            c++;
        }
    }

    print(a,b,c,line)
    print(a + c === b ? "YES" : "NO")
}

const problems = parseInt(readline());

for (var i = 0; i < problems; i++) {
    const line = readline();

    var a = 0;
    var b = 0;
    var c = 0;

    for (var j = 0; j < line.length; j++) {
        if (line.charAt(j) === 'A') {
            a++;
        }
        if (line.charAt(j) === 'B') {
            b++;
        }
        if (line.charAt(j) === 'C') {
            c++;
        }
    }

    print(a + c === b ? "YES" : "NO")
}

const problems = parseInt(readline());

for (var i = 0; i < problems; i++) {
    const line = readline();

    var a = 0;
    var b = 0;
    var c = 0;

    for (var j = 0; j < line.length; j++) {
        if (line.charAt[j] === 'A') {
            a++;
        }
        if (line.charAt[j] === 'B') {
            b++;
        }
        if (line.charAt[j] === 'C') {
            c++;
        }
    }

    print(a + c === b ? "YES" : "NO")
}

const problems = parseInt(readline());

for (var i = 0; i < problems; i++) {
    const line = readline();

    var a = 0;
    var b = 0;
    var c = 0;

    for (var j = 0; j < line.length; j++) {
        if (line.charAt[j] === 'a') {
            a++;
        }
        if (line.charAt[j] === 'b') {
            b++;
        }
        if (line.charAt[j] === 'c') {
            c++;
        }
    }

    print(a + c === b ? "YES" : "NO")
}

var n = parseInt(readline());
for(var i = 0; i < n; i++){
    var arr = readline().split('')
    var dir = {A: 0, B:0, C:0};

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

    print(dir['A'] + dir['C'] === dir['B'] ? 'YES': 'NO')
}

var a = readline();
var b = readline();
var c = readline();
var d = readline();
var k = readline();
var t = readline();

function canAllRemove(str){

    while(true){

        if(!str.length){
            return 'YES'
        }
        var test1 = str.indexOf('A');
        var test2 = str.indexOf('B');
        var test3 = str.indexOf('C');

        if(test1 != -1 && test2 != -1){
            str = str.replace('A','');
            str = str.replace('B','')
        }else if (test2 != -1 && test3 != -1){
            str = str.replace('B','');
            str = str.replace('C','')
        }else {
            return 'NO'
        }

    }

    // var obj = {};

    // for(let i = 0; i<str.length; i++){
    //     if(obj.hasOwnProperty(str[i])) {
    //         obj[str[i]]++;
    //     }else {
    //         obj[str[i]] = 1;
    //     }
    // }

    // if(str.indexOf('C') !== -1){
    //     return  obj['A'] + obj['C'] == obj['B'] ? 'YES' : 'NO'
    // }else {
    //     return obj['A'] == obj['B'] ? 'YES' : 'NO'
    // }
}

print(canAllRemove(a))
print(canAllRemove(b))
print(canAllRemove(c))
print(canAllRemove(d))
print(canAllRemove(k))
print(canAllRemove(t))

var a = readline();
var b = readline();
var c = readline();
var d = readline();
var k = readline();
var t = readline();

function canAllRemove(str){

    while(true){

        if(!str){
            return 'YES'
        }
        var test1 = str.indexOf('A');
        var test2 = str.indexOf('B');
        var test3 = str.indexOf('C');

        if(test1 != -1 && test2 != -1){
            str = str.replace('A','');
            str = str.replace('B','')
        }else if (test2 != -1 && test3 != -1){
            str = str.replace('B','');
            str = str.replace('C','')
        }else {
            return 'NO'
        }

    }
}

print(canAllRemove(a))
print(canAllRemove(b))
print(canAllRemove(c))
print(canAllRemove(d))
print(canAllRemove(k))
print(canAllRemove(t))

var a = readline();
var b = readline();
var c = readline();
var d = readline();
var k = readline();
var t = readline();

function canAllRemove(str){

    while(true){

        if(!str.length){
            return 'YES'
        }
        var test1 = str.indexOf('A');
        var test2 = str.indexOf('B');
        var test3 = str.indexOf('C');

        if(test1 != -1 && test2 != -1){
            str = str.replace('A','');
            str = str.replace('B','')
        }else if (test2 != -1 && test3 != -1){
            str = str.replace('B','');
            str = str.replace('C','')
        }else {
            return 'NO'
        }

    }
}

print(canAllRemove(a))
print(canAllRemove(b))
print(canAllRemove(c))
print(canAllRemove(d))
print(canAllRemove(k))
print(canAllRemove(t))


Are you going to Scarborough Fair?Parsley, sage, rosemary and thyme.Remember me to one who lives there.He once was the true love of mine.Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.Although the girl wants to help, Willem insists on doing it by himself.Grick gave Willem a string of length n.Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (from l-th to r-th, including l and r) are changed into c2. String is 1-indexed.Grick wants to know the final string after all the m operations.

The first line contains two integers n and m (1 ≤ n, m ≤ 100). The second line contains a string s of length n, consisting of lowercase English letters. Each of the next m lines contains four parameters l, r, c1, c2 (1 ≤ l ≤ r ≤ n, c1, c2 are lowercase English letters), separated by space.

Output string s after performing m operations described above.

NoteFor the second example:After the first operation, the string is wxxak.After the second operation, the string is waaak.After the third operation, the string is gaaak.

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
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';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//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 one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var s = nextCharArray();
  for(var i = 0; i < M; i++){
    var tmp = nextStrArray();
    var L = myconv(tmp[0], 1) - 1;
    var R = myconv(tmp[1], 1) - 1;
    var mae = tmp[2];
    var ato = tmp[3];
    for(var j = L; j <= R; j++){
      if(s[j] == mae){
        s[j] = ato;
      }
    }
  }
  myout(myconv(s, 0));
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let str = [];

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

  if (c === 1) {
    c++;
    str = [...d];
    return;
  }

  let [l, r, c1, c2] = d.split(' ');

  l = Number(l);
  r = Number(r);

  for (let i = l - 1; i < r; i++) {
    if (str[i] === c1) {
      str[i] = c2;
    }
  }

  c++;
});

rl.on('close', () => {
  console.log(str.join(''));
});

let input = [];

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

RL.on('line', (line) => {
    input.push(line);
});

RL.on('close', () => {
    const setCharAt = (str, index, chr) => {
        if(index > str.length) return str;
        return str.substr(0, index) + chr + str.substr(index+1);
    }

    let {0:n, 1:m} = {...input[0].split(' ')};
    n = parseInt(n); m = parseInt(m);
    str = input[1];
    for(let i = 0; i < m; i++){
        let {0:j, 1:r, 2:c1, 3:c2} = {...input[i+2].split(' ')};
        j = parseInt(j); r = parseInt(r);

        for(let k = j; k<=r; k++){
            if(str.charAt(k-1) === c1){
                str = setCharAt(str, k-1, c2);
            }
        }
    }

    console.log(str);
});

function main() {
    var line = readline().split(' ');

    var n = parseInt(line[0]) , m = parseInt(line[1]) , s = readline();

    var v = [];

    for(var i = 0; i < s.length; i++) v.push( s[i] );

    s = "";

    for(var i = 0; i < m; ++i){
        var line = readline().split(' ');
        var l = parseInt(line[0]) - 1 ,
            r = parseInt(line[1]) - 1 ,
            c1= line[2], c2 = line[3];
        while( l <= r ){
            if( v[l] == c1 )
                v[l] = c2;
            l++;
        }
    }

    for(var i = 0; i < v.length; i++) s += v[i];

    print( s );
    return 0;
}

main();

var str="";
var ar=[];
function go(l,r,x,c) {
	for(var i =l-1;i<r;i++) {
		if(ar[i]===x) ar[i] = c;
	}
}
var n = readline().split(' ');
str = readline();
ar= str.split("");
while(n[1]--) {
	var k = readline().split(' ');
	go(k[0],k[1],k[2],k[3]);
}
var ans ="";
for(var i = 0;i<ar.length;i++) ans +=ar[i];
print(ans);

var a = readline().split(' ');
var s = readline();
for(var i = 0 ; i < a[1] ; i++){
	var k = readline().split(' ');
	var y="";
	for(var q = 0 ; q < parseInt(k[0])-1 ; q++){
		y=y+s.charAt(q);
	}

	for(var q = parseInt(k[0])-1 ; q < parseInt(k[1]) ; q++){
		if(s.charAt(q)==k[2]) y=y+k[3];
		else y=y+s.charAt(q);
	}

	for(var j = parseInt(k[1]); j < parseInt(a[0]) ; j++){
		y=y+s.charAt(j);
	}

	s=y;
}
print(s);

nm = readline().split(' ').map(Number);
str = readline().split('');

var n = nm[0], m = nm[1];

for (var i = 0; i < m; i++) {
	newStr = readline().split(' ');

	var l = newStr[0], r = newStr[1], c1 = newStr[2], c2 = newStr[3];

	for (var j = l - 1; j < r; j++) {
		if (str[j] == c1) {
			str[j] = c2;
		};
	};
};

print(str.join(''));

function main() {
    var line = readline().split(' ');
    //print(parseInt(line[0]) + parseInt(line[1]))
    var n = parseInt(line[0]) , m = parseInt(line[1]) , s = readline();

    for(var i = 0; i < m; ++i){
        var line = readline().split(' ');
        var l = parseInt(line[0]) - 1 ,
            r = parseInt(line[1]) - 1 ,
            c1= line[2], c2 = line[3];
        while( l <= r ){
            if( s[l] == c1 ) {
                s[l] = c2;
            }
            l++;
        }
    }

    print( s );
    return 0;
}

main();

function main() {
    var line = readline().split(' ');
    //print(parseInt(line[0]) + parseInt(line[1]))
    var n = parseInt(line[0]) , m = parseInt(line[1]) , s = readline();

    for(var i = 0; i < m; ++i){
        var line = readline().split(' ');
        var l = parseInt(line[0]) - 1 ,
            r = parseInt(line[1]) - 1 ,
            c1= line[2], c2 = line[3];
        while( l <= r ){
            print( s[l] , c1 , c2 );
            if( s[l] == c1 ) {
                s[l] = c2;
            }
            l++;
        }
    }

    print( s );
    return 0;
}

main();

function main() {
    var line = readline().split(' ');
    //print(parseInt(line[0]) + parseInt(line[1]))
    var n = parseInt(line[0]) , m = parseInt(line[1]) , s = readline();

    print( n , m , s );

    return 0;

    for(var i = 0; i < m; ++i){
        var line = readline().split(' ');
        var l = parseInt(line[0]) - 2 ,
            r = parseInt(line[1]) - 1 ,
            c1= line[2], c2 = line[3];
        while( l++ < r )
            if( s[l] == c1 )
                s[l] = c2;
    }

    print( s );
    return 0;
}

main();

var a = readline().split(' ');
var s = readline();
for(var i = 0 ; i < a[1] ; i++){
	var k = readline().split(' ');
	var y="";
	for(var q = 0 ; q < k[0]-1 ; q++){
		y=y+s.charAt(q);
	}

	for(var q = k[0]-1 ; q < k[1] ; q++){
		if(s.charAt(q)==k[2]) y=y+k[3];
		else y=y+s.charAt(q);
	}

	for(var q = k[1] ; q < a[0] ; q++){
		y=y+s.charAt(q);
	}
	s=y;
}
print(s);

    var line = readline().split(' ');
    //print(parseInt(line[0]) + parseInt(line[1]))
    var n = parseInt(line[0]) , m = parseInt(line[1]) , s = readline();

    for(var i = 0; i < m; ++i){
        var line = readline().split(' ');
        var l = parseInt(line[0]) - 1 ,
            r = parseInt(line[1]) - 1 ,
            c1= line[2], c2 = line[3];
        while( l++ <= r )
            if( s[l] == c1 )
                s[l] = c2;
    }

    print( s );

function main() {
    var line = readline().split(' ');
    //print(parseInt(line[0]) + parseInt(line[1]))
    var n = parseInt(line[0]) , m = parseInt(line[1]) , s = readline();

    for(var i = 0; i < m; ++i){
        var line = readline().split(' ');
        var l = parseInt(line[0]) - 1 ,
            r = parseInt(line[1]) - 1 ,
            c1= line[2], c2 = line[3];
        while( l <= r ){
            if( s[l] == c1 ) {
                s[l] = c2;
                print( s[l] , c1 , c2 );
            }
            l++;
        }
    }

    print( s );
    return 0;
}

main();

    var line = readline().split(' ');
    //print(parseInt(line[0]) + parseInt(line[1]))
    var n = parseInt(line[0]) , m = parseInt(line[1]) , s = readline();

    for(var i = 0; i < m; ++i){
        var line = readline().split(' ');
        var l = parseInt(line[0]) - 2 ,
            r = parseInt(line[1]) - 1 ,
            c1= line[2], c2 = line[3];
        while( l++ < r )
            if( s[l] == c1 )
                s[l] = c2;
    }

    print( s );