'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 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);
}

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);
  }
}

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);
        }
    }
}

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 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);
        }
    }
}


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

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))


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);

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);

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

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


function solve() {
   read();
   const arr = readArray(Number);
   arr.sort(sortF);
   write(arr[arr.length - 1] + arr[arr.length - 2]);
}

function init() {
   try {
      var T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e + e.stack);
   }
}

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1n;
   while(curN) {
      if (curN & 1n) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1n;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

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

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

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

   var path = require('path');

   var inTextName;
   var outTextName;

   var needWriteFile = false;

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

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

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

function solveAll(inputs) {
    inputs.forEach(input => {
        // code here
        const list = input[1].split(' ').map(o => parseInt(o))
        list.sort((a,b) => b-a);
        console.log(list[0] + list[1]);
    });
}

const rl = require('readline').createInterface(process.stdin, process.stdout);
let testCase = 0; const inputs = []
subInputs = []; subInputLen = 2;
rl.on('line', (data) => {
    if (testCase === 0) testCase = parseInt(data)
    else {
        subInputs.push(data)
        if (subInputs.length === subInputLen) {inputs.push(subInputs); subInputs = []}
        if (inputs.length === testCase) { solveAll(inputs); rl.close() }
    }
})

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

let ls = [];

function solve(){
    let l = 0;
    const t = parseInt(ls[l++]);
    for (let u = 0; u < t; u++){
        const n = parseInt(ls[l++]);
        const a = ls[l++].split(' ').map(i => parseInt(i));
        a.sort(function(a, b){return b - a});
        const ans = a[0] + a[1];
        console.log(ans);
    }
}

rl.on('line', (l) => ls.push(l));
rl.on('close', () => solve());

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

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

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

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);
        let arr = readline().split(' ').map(Number);

        let max = -Infinity;
        let maxIndex = -1;
        let max2 = -Infinity;
        let max2Index = -1;

        for (let i = 0; i < n; i++) {
            if (arr[i] > max) {
                max2 = max;
                max2Index = maxIndex;
                max = arr[i];
                maxIndex = i;
            } else if (arr[i] > max2) {
                max2 = arr[i];
                max2Index = i;
            }
        }

        console.log(max + max2);
    }
}

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 e = 0;
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number).sort(function(a, b){return b - a});
            console.log(k[0] + k[1]);
        }
    }
});

'use strict';

var readline = require('readline');

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

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

function solve(n, a) {
  a.sort((a, b) => b - a);
  return a[0] + a[1];
}

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

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

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var n = lines[0];
    var e = 0;
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j];
        }else{
            var k = lines[j].split(' ').map(Number).sort(function(a, b){return b - a});
            console.log(k[0] + k[1]);
        }
    }
});

'use strict'; /*jslint node:true, browser:true, es6:true*/
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
const print = console.log
const lines = []
rl.on('line', line => {
    lines.push(line);
});
rl.on('close', main)
let rli = 0;
function readline() {
    return lines[rli++];
}

const EPS = 1e-6;

let calc = (arr)=>{
  arr.sort((a, b)=>b-a);
  return arr[0]+arr[1]
};

function main() {
    let T = +readline();
    while (T--){
      let n = readline();
      let arr = readline().split(' ').map(a=>+a);
      print(calc(arr));
    }
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var list = nextIntArray(N);
		var max = 0;
		for(var i = 0; i < N; i++){
			for(var j = i + 1; j < N; j++){
				max = Math.max(max, list[i] + list[j]);
			}
		}
		myout(max);
	}
}

var x = parseInt(readline());
var z =[];
for(var i=0; i<x; i++) {
    var l = parseInt(readline());
    var n = readline().split(' ').map(a => +a);

    n.sort(function(a, b){return b - a});
    print(n[0] + n[1])

}

function solveAll(inputs) {
    inputs.forEach(input => {
        // code here
        const list = input[1].split(' ').map(o => parseInt(o))
        list.sort((a,b) => b > a);
        console.log(list[0] + list[1]);
    });
}

const rl = require('readline').createInterface(process.stdin, process.stdout);
let testCase = 0; const inputs = []
subInputs = []; subInputLen = 2;
rl.on('line', (data) => {
    if (testCase === 0) testCase = parseInt(data)
    else {
        subInputs.push(data)
        if (subInputs.length === subInputLen) {inputs.push(subInputs); subInputs = []}
        if (inputs.length === testCase) { solveAll(inputs); rl.close() };
    }
})

function solveAll(inputs) {
    inputs.forEach(input => {
        // code here
        const list = input[1].split(' ').map(o => parseInt(o))
        list.sort(); list.reverse();
        console.log(list[0] + list[1]);
    });
}

const rl = require('readline').createInterface(process.stdin, process.stdout);
let testCase = 0; const inputs = []
subInputs = []; subInputLen = 2;
rl.on('line', (data) => {
    if (testCase === 0) testCase = parseInt(data)
    else {
        subInputs.push(data)
        if (subInputs.length === subInputLen) {inputs.push(subInputs); subInputs = []}
        if (inputs.length === testCase) { solveAll(inputs); rl.close() };
    }
})

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

let ls = [];

function solve(){
    let l = 0;
    const t = parseInt(ls[l++]);
    for (let u = 0; u < t; u++){
        const n = parseInt(ls[l++]);
        const a = ls[l++].split(' ').map(i => parseInt(i));
        a.sort();
        const ans = a[a.length - 1] + a[a.length - 2];
        console.log(ans);
    }
}

rl.on('line', (l) => ls.push(l));
rl.on('close', () => solve());