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

function Main(){
    // input in nodeJs
	var t = nextInt();
	while(hasNext()){
		let n= nextInt();
        let a= nextIntArray(n);
        let stop = false;
        for(let i=n-1;i>=0;i-=2){
            if(i+1<n && a[i]>a[i+1]) {
                myout("NO");
                stop = true;
                break;
            }
            if(i+2<n && a[i]>a[i+2]) {
                myout("NO");
                stop = true;
                break;
            }
            if(i-1>=0 && i+1<n && a[i-1]>a[i+1]) {
                myout("NO");
                stop = true;
                break;
            }
            if(i-1>=0 && i+2<n && a[i-1]>a[i+2]) {
                myout("NO");
                stop = true;
                break;
            }
        }
        if (stop) continue;
        myout("YES")
	}
}

var tests = parseInt(readline());
    var n;
    var a;

    for (var t=0; t < tests; t++) {
        n = parseInt(readline());
        a = readline().split(' ').map(x=>parseInt(x));
        var prevMax = 0;
        var start = 0;
        var ans = 'YES';
        if (a.length & 1) {
            start = 1;
            prevMax = a[0];
        }
        for (var i = start; i < n; i+=2) {
            if (a[i] < prevMax || a[i+1] < prevMax) {
                ans = 'NO';
                break;
            }
            prevMax = Math.max(a[i], a[i+1]);
        }
        print(ans);
    }

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

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

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

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

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

const calc = (n, a)=>{
    if (n < 3) return 'YES';

    if (n % 2 === 1) {
        a.unshift(0);
        n++;
    }

    for (let i = 0; i < n; i += 2) {
        let max = Math.max(a[i], a[i + 1]);
        let min = Math.min(a[i], a[i + 1]);
        a[i] = min;
        a[i + 1] = max;
    }

    for (let i = 1; i < n; i++) {
        if (a[i] < a[i - 1]) return 'NO';
    }

    return 'YES';
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let n = +readline();
        let a = ra();
        console.log(`${calc(n, a)}`);
    }
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    if (n === 1) {
      console.log("YES");
      continue;
    }
    let narr = [],
      i = 0;
    if (n % 2) narr.push(arr[i++]);
    while (i + 1 < n) {
      if (arr[i] > arr[i + 1]) {
        narr.push(arr[i + 1]);
        narr.push(arr[i]);
      } else {
        narr.push(arr[i]);
        narr.push(arr[i + 1]);
      }
      i = i + 2;
    }
    let ans = true;
    for (let i = 0; i < n - 1; i++) {
      if (narr[i] > narr[i + 1]) {
        ans = false;
        break;
      }
    }
    if (ans) console.log("YES");
    else console.log("NO");
  }
};
solve();

'use strict';
const readline = require('readline');
const util = require('util');
const lineReader = readline.createInterface({
    input: process.stdin,
});
let inputPos = 0;
const inputWords = [];
lineReader.on('line', (line) => {
    inputWords.push.apply(inputWords, line.split(' ').filter(s => s != ''));
});
lineReader.on('close', main);
function check(b) {
    if (!b) {
        process.stderr.write(`${new Error().stack}\n`);
        process.exit(-1);
    }
}
function printf(...args) {
    process.stdout.write(util.format(...args));
}
function nextInt() {
    return Math.trunc(Number(inputWords[inputPos++]));
}
function nextStr() {
    return inputWords[inputPos++];
}
function af(l) {
    return Array.from({ length: l });
}
const INIT = -1;
const INF = Infinity;
let n;
let a;
function solve() {
    for (let i = n - 1; i > 0; i -= 2) {
        if (a[i] < a[i - 1]) {
            [a[i], a[i - 1]] = [a[i - 1], a[i]];
        }
    }
    for (let i = 0; i + 1 < n; i++) {
        if (a[i] > a[i + 1]) {
            return false;
        }
    }
    return true;
}
function main() {
    let tc = nextInt();
    while (tc-- > 0) {
        n = nextInt();
        a = af(n);
        for (let i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        printf("%s\n", (solve() ? "YES" : "NO"));
    }
}

'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, nums) {
  const res = [];
  let start = 0;
  if (n & 1) {
    res.push(nums[0]);
    start = 1;
  }
  for (let i = start; i < n; i += 2) {
    var _res;
    let a = nums[i],
        b = nums[i + 1];
    if (a > b) [a, b] = [b, a];
    if (a < ((_res = res[i - 1]) !== null && _res !== void 0 ? _res : -Infinity)) {
      console.log('NO');
      return;
    }
    res.push(a, b);
  }
  console.log('YES');
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const n = Number(await read());
    const a = (await read()).split(' ').map(Number);
    solve(n, a);
  }
}

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

'use strict';

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

const pcalc = function(){
  print(calc.apply(null, arguments)); }

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

// SOLUTION

const calc = (n, A)=>{
  let Bl = [];
  let Bm = 0;
  let Br = [];
  for (let i=n-1; i>=0; i--){
    let a = A[i];
    let canChoose = (n-i)%2==0;
    if (!canChoose){
      // push prev Bm?
      Bm = a;
    } else {
      if (Bm<a){
        Bl.push(Bm);
        Br.push(a);
      } else {
        Bl.push(a);
        Br.push(Bm);
      }
      Bm = 0;
    }
  }
  if (Bm) // why?
    Bl.push(Bm);
  L(A, {Bl, Br})
  let C = [];
  while (Bl.length || Br.length){
    if (Bl.length<Br.length){
      C.push(Br.pop())
    } else if (Bl.length>Br.length) {
      C.push(Bl.pop())
    } else {
      let lBl = Bl[Bl.length-1]
      let lBr = Br[Br.length-1]
      if (lBl<lBr){
        C.push(Bl.pop())
      } else {
        C.push(Br.pop())
      }
    }
  }
  L(C)
  for (let i=0; i<n-1; i++){
    if (C[i]>C[i+1])
      return false;
  }
  return true;
  let ans = 0;
  return ans;
};

function main() {
    let T = +readline()
    while (T--){
      let [n] = ra();
      let A = ra();
      L('Ans:');
      print(calc(n, A) ? 'YES' : 'NO');
    }
}

const readline = require('readline')

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

function solve(n, arr) {
    for (let i = arr.length - 1; i >= 0; i -= 2) {
        if (i && arr[i] < arr[i - 1]) {
            [arr[i], arr[i - 1]] = [arr[i - 1], arr[i]]
        }
    }
    // console.log(arr)
    for (let i = 1; i < arr.length; i++) {
        if (arr[i] < arr[i - 1]) return false
    }
    return true
}

var tests = parseInt(readline());
    var n;
    var a;

    for (var t=0; t < tests; t++) {
        n = parseInt(readline());
        a = readline().split(' ').map(x=>parseInt(x));
        var prevMax = 0;
        var start = 0;
        var ans = 'YES';
        if (a.length & 1) {
            start = 1;
            prevMax = a[1];
        }
        for (var i = start; i < n; i+=2) {
            if (a[i] < prevMax || a[i+1] < prevMax) {
                ans = 'NO';
                break;
            }
            prevMax = Math.max(a[i], a[i+1]);
        }
        print(ans);
    }

var tests = parseInt(readline());
    var n;
    var a;

    for (var t=0; t < tests; t++) {
        n = parseInt(readline());
        a = readline().split(' ').map(x=>parseInt(x));
        var prevMax = 0;
        var ans = 'YES';
        for (var i = 0; i < n; i+=2) {
            if (i == n-1) {
                if (a[i] < a[i-1] && a[i] < a[i-2]) {
                    ans = 'NO';
                    break;
                }
            } else {
                if (a[i] < prevMax || a[i+1] < prevMax) {
                    ans = 'NO';
                    break;
                }
                prevMax = Math.max(a[i], a[i+1]);
            }
        }
        print(ans);
    }

 var tests = parseInt(readline());
    var n;
    var arr;

    for (var t=0; t < tests; t++) {
        n = parseInt(readline());
        arr = readline().split(' ').map(x=>parseInt(x));
        var prevMax = 0;
        var ans = 'YES';
        for (var i = 0; i < n; i+=2) {
            var max = arr[i];
            if (prevMax > max) {
                ans = 'NO';
                break;
            }
            if (i != n-1) {
                max = Math.max(arr[i], arr[i+1]);
                if (arr[i+1] < prevMax) {
                    ans = 'NO';
                    break;
                }
            }

            prevMax = max;
        }
        print(ans);
    }

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

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

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

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

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

const calc = (n, a)=>{
    if (n < 3) return 'YES';

    if (n % 2 === 1) {
        a.unshift(0);
        n++;
    }

    for (let i = n - 2; i > 0; i -= 2) {
        let maxr = Math.max(a[i], a[i + 1]);
        let maxl = Math.max(a[i - 1], a[i - 2]);
        if (maxl > maxr) return 'NO';
    }

    return 'YES';
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let n = +readline();
        let a = ra();
        console.log(`${calc(n, a)}`);
    }
}

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

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

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

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

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

const calc = (n, a)=>{
    if (n < 3) return 'YES';

    if (n % 2 === 1) {
        a.unshift(0);
        n++;
    }

    // console.log(`DEBUG a`, a);

    for (let i = n - 2; i > 0; i--) {
        let maxr = Math.max(a[i], a[i + 1]);
        let maxl = Math.max(a[i - 1], a[i - 2]);
        // console.log(`DEBUG i ${i} maxl ${maxl} maxr ${maxr}`);
        if (maxl > maxr) return 'NO';
    }

    return 'YES';
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let n = +readline();
        let a = ra();
        console.log(`${calc(n, a)}`);
    }
}


function solve() {
   var str = read();
   var str1 = str + 'a';
   var str2 = str1.split('').reverse().join('');
   var str3 = 'a' + str;
   var str4 = str3.split('').reverse().join('');
   if (str1 !== str2) {
      write('YES');
      write(str1);
      return;
   }
   if (str3 !== str4) {
      write('YES');
      write(str3);
      return;
   }
   write('no');
}

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

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

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }
   fs.readFile(inTextName ? path.join(__dirname, inTextName) : 0, 'utf8', function(err, data) {
      MEMORY = data.split('\r\n');
      init();
   });
} else {
   init();
}

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function solve() {
   var str = read();
   var str1 = str + 'a';
   var str2 = str1.split('').reverse().join('');
   var str3 = 'a' + str;
   var str4 = str3.split('').reverse().join('');
   if (str1 !== str2) {
      write('YES');
      write(str1);
      return;
   }
   if (str3 !== str4) {
      write('YES');
      write(str3);
      return;
   }
   write('no');
}

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

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

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', function(err, data) {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

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) {
    let a = 'a' + str
    let b = str + 'a'
    if (a === a.split('').reverse().join('')) {
        if (b === b.split('').reverse().join('')) {
            console.log('NO')
        } else {
            console.log('YES')
            console.log(b)
        }
    } else {
        console.log('YES')
        console.log(a)
    }
}

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

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

var maxN = 21
var mod = 1000000007

// Make a Snippet for the code above this and then write your logic in main();

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

  Array(Number(xx)).fill(1).map((t, i) => {
    // const a = parseInt(readline());
    // var [n, p, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    var a = readline().split('').map((x, iii) => {
      return x
    });
    var allA = true
    for (let j = 0; j < a.length; j++) {
      if (a[j] !== 'a') allA = false
    }
    if (allA) return console.log('NO')

    var ans = []
    var once = true
    for (let j = 0; j < a.length; j++) {
      if (a[a.length - j - 1] !== 'a' && once) {
        ans.push('a')
        once = false
      }
      ans.push(a[j])
    }
    console.log('YES')
    console.log(ans.join(''))
    // console.log(a)
  })
}

let input = '';

process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
    const lines = input.trim().split('\n').slice(1);

    for (let i=0; i<lines.length; i++) {
        const line = lines[i].trim();
        const line1 = 'a' + line;
        const line2 = line + 'a';
        let line1Flag = true, line2Flag = true;

        for (let j=0; j<line1.length; j++) {
            if (line1[j] !== line1[line1.length-1-j]) {
                line1Flag = false;
            }

            if (line2[j] !== line2[line2.length-1-j]) {
                line2Flag = false;
            }
        }

        if (line1Flag && line2Flag) {
            console.log('NO');
        } else if (line1Flag) {
            console.log('YES');
            console.log(line2);
        } else {
            console.log('YES');
            console.log(line1);
        }

    }
})

//////////////////////  Nodejs / Javascript Problem Solving /////////////////
/////////////////////* @author  Nawab Khairuzzaman Mohammad Kibria *////////

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let currentLine = 0;
let inputString = "";
process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

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

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

///////////////////////// END BASIC IO STREAM TEMPLATE //////////////////////

function insert(main_string, ins_string, pos) {
  if (typeof pos == "undefined") {
    pos = 0;
  }
  if (typeof ins_string == "undefined") {
    ins_string = "";
  }
  return main_string.slice(0, pos) + ins_string + main_string.slice(pos);
}

function reverseString(str) {
  // return a new array of strings
  const arrayStrings = str.split("");

  // reverse the new created array elements
  const reverseArray = arrayStrings.reverse();

  // join all elements of the array into a string
  const joinArray = reverseArray.join("");

  // return the reversed string
  return joinArray;
}

// Additional Functions ////////
function main() {
  let testCase = +readLine();
  const LETTER = "a";
  while (testCase--) {
    let f = 0;
    const word = readLine();
    let n = word.length + 1;
    let m = n - 1;
    let newWord = word.split("").filter((x) => {
      if (x !== "a") return x;
    });
    if (newWord.length === 0) {
      console.log("NO");
    } else {
      for (let i = 0; i < n / 2; i++) {
        let word1 = word.slice();
        let word2 = word.slice();
        const newWord1 = insert(word1, "a", i);
        const newWord2 = insert(word2, "a", m);
        const revWord1 = reverseString(newWord1);
        const revWord2 = reverseString(newWord2);
        if (revWord1 !== newWord1) {
          console.log("YES");
          console.log(newWord1);
          f = 1;
          break;
        } else if (revWord2 !== newWord2) {
          console.log("YES");
          console.log(newWord2);
          f = 1;
          break;
        }
        m--;
      }
    }
  }
}

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

//Don't have to see. end------------------------------------------

function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var s = next();
		var isOK = false;
		for(var j = 0; j < s.length; j++){
			if(s[j] != "a"){
				isOK = true;
				break;
			}
		}
		if(isOK){
			myout("YES");
			var s1 = s + "a";
			var isOK2 = false;
			for(var j = 0; j < s1.length; j++){
				if(s1[j] != s1[s1.length - 1 - j]){
					isOK2 = true;
					break;
				}
			}
			if(isOK2){
				myout(s + "a");
			}else{
				myout("a" + s);
			}
		}else{
			myout("NO");
		}
	}
}

function solve() {
   var str = read();
   var str1 = str + 'a';
   var str2 = str1.split('').reverse().join('');
   var str3 = 'a' + str;
   var str4 = str3.split('').reverse().join('');
   if (str1 !== str2) {
      write('YES');
      write(str1);
      return;
   }
   if (str3 !== str4) {
      write('YES');
      write(str3);
      return;
   }
   write('no');
}

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

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

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', function(err, data) {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var readable = process.stdin;
      readable.once('readable', function() {
         MEMORY = ('' + readable.read()).split('\r\n');
         init();
      });
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

function reverseString(str) {
    return str;
}

var t=readline();
while(t--)
{
	var s=readline();
	var c=0;
	for(i=0;i<s.length;i++)
	{
		if(s[i]!='a')
		c=1;
	}
	if(c==0)
	print("NO");
	else{
		var s1='a'+s;
		var str="";
		var s2=s+'a';
		for(i=0;i<s1.length;i++)
		  str+=s1[s1.length-i-1];
		if(s1!=str){ print("YES");
		print(s1);
		}
		else {
			print("YES");
			print(s2);
		}
	}
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    let s = rl();

    if (!palindrome(s + "a")) {
      cl("Yes");
      cl(s + "a");
    } else if (!palindrome("a" + s)) {
      cl("Yes");
      cl("a" + s);
    } else {
      cl("NO");
    }
  }
  function palindrome(_str) {
    return _str == _str.split("").reverse().join("");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    let str = rl();

    if (checkPalindrome("a" + str) && checkPalindrome(str + "a")) {
      cl("NO");
    } else {
      cl("YES");
      cl(str.split("").reverse().join("") + "a");
    }
  }
  function checkPalindrome(_str) {
    return _str == _str.split("").reverse().join("");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    let str = rl();

    if (checkPalindrome("a" + str) && checkPalindrome(str + "a")) {
      cl("NO");
    } else {
      cl("YES");
      cl(str + "a");
    }
  }
  function checkPalindrome(_str) {
    return _str == _str.split("").reverse().join("");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    let str = rl().split("");
    let flags = false;
    let temp = "";

    for (let i = 0; i < str.length; i++) {
      // cl(str.join(""));
      str.splice(i, 0, "a");
      if (!checkPalindrome(str)) {
        flags = true;
        temp = [...str];
        break;
      }
      str.reverse().splice(i, 1);
    }
    if (!flags) {
      cl("NO");
    } else {
      cl("YES");
      cl(temp.reverse().join(""));
    }
  }
  function checkPalindrome(_str) {
    for (let i = 0; i < _str.length; i++) {
      if (_str[i] != _str[_str.length - i - 1]) {
        return false;
      }
    }
    return true;
    // return _str.join("") == _str.reverse().join("");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    let str = rl().split("");
    let flags = false;
    let temp = "";

    for (let i = 0; i < str.length; i++) {
      // cl(str.join(""));
      str.splice(i, 0, "a");
      if (!checkPalindrome(str)) {
        flags = true;
        temp = [...str];
      }
      str.reverse().splice(i, 1);
    }
    if (!flags) {
      cl("NO");
    } else {
      cl("YES");
      cl(temp.join(""));
    }

    // cl(checkPalindrome(str));
  }
  function checkPalindrome(_str) {
    return _str.join("") == _str.reverse().join("");
  }
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let currentLine = 0;
function readLine() {
  return standardInputString[currentLine++];
}
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function main() {
  const numArray = (a) => a.split(" ").map((line) => +line),
    cl = console.log,
    rl = readLine,
    tc = rl();

  for (let i = 0; i < tc; i++) {
    let str = rl().split("");
    const loop = str.length;
    let flags = false;

    for (let i = 0; i < loop; i++) {
      str.splice(i, 0, "a");
      if (!checkPalindrome(str)) {
        flags = true;
      }
      str.reverse("").splice(i, 1);
      // cl(str.join(""));
    }
    if (!flags) {
      cl("No");
    } else {
      cl("Yes");
      str.unshift("a");
      cl(str.join(""));
    }

    // cl(checkPalindrome(str));
  }
  function checkPalindrome(_str) {
    return _str.join("") == _str.reverse().join("");
  }
}

function solve() {
   var str = read();
   var str1 = str + 'a';
   var str2 = str1.split('').reverse().join('');
   var str3 = 'a' + str;
   var str4 = str3.split('').reverse().join('');
   if (str1 !== str2) {
      write('YES');
      write(str1);
      return;
   }
   if (str3 !== str4) {
      write('YES');
      write(str3);
      return;
   }
   write('no');
}

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

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

function readArray(mapF) {
   var res = read().split(' ');
   if (mapF) {
      res = res.map(mapF);
   }
   return res;
}

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;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', function(err, data) {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var readable = process.stdin;
      readable.once('readable', function() {
         MEMORY = ('' + readable.read()).split('\r\n');
         init();
      });
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   if (isNode) {
      return MEMORY;
   }
   var res = [];
   var x;
   while (x = read()) {
      res.push(x);
   }
   return res;
}

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

var maxN = 21
var mod = 1000000007

// Make a Snippet for the code above this and then write your logic in main();

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

  Array(Number(xx)).fill(1).map((t, i) => {
    // const a = parseInt(readline());
    // var [n, p, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    var a = readline().split('').map((x, iii) => {
      return x
    });
    if (a.length ===1 )return console.log('NO')
    var ans= []
    var once= true
    for (let j = 0; j < a.length; j++) {
      if(a[a.length-j-1] !== 'a' && once) {
        ans.push('a')
        once = false
      }
      ans.push(a[j])
    }
    console.log('YES')
    console.log(ans.join(''))
    // console.log(a)
  })
}

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

var maxN = 21
var mod = 1000000007

// Make a Snippet for the code above this and then write your logic in main();

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

  Array(Number(xx)).fill(1).map((t, i) => {
    // const a = parseInt(readline());
    // var [n, p, k] = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // });
    var a = readline().split('').map((x, iii) => {
      return x
    });
    if (a.length ===1 )return console.log('NO')
    if(a[0] === 'a') a.push('s')
    else a.push('a')
    console.log('YES')
    console.log(a.join(''))
    // console.log(a)
  })
}

let input = '';

process.stdin.on('data', str => input += str)
process.stdin.on('end', () => {
    const lines = input.trim().split('\n').slice(1);

    for (let i=0; i<lines.length; i++) {
        const line = lines[i].trim();
        let nextLine = '';

        if (line[line.length-1] !== 'a') {
            nextLine = 'a' + line;
        } else if (line[0] !== 'a') {
            nextLine = line + 'a';
        }

        if (nextLine.length === 0) {
            console.log('NO')
        } else {
            console.log(`YES\n${nextLine}`);
        }
    }
})


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

var height = []

function main() {
    var xx = Number(readline())
    Array(Number(xx)).fill(1).map((t, i) => {

        var x = parseInt(readline())
        var a = readline().split(' ').map((x, i) => {
            return parseInt(x)
        })
        var b = a.slice()
        a = a.sort((a, b) => a - b)

        var l = -1
        var m
        var r = x //Number.max integer
        while (r > l + 1) {

            m = Math.floor((l + r) / 2)
            // console.log(l, r,m)

            if (find(a, m)) r = m
            else l = m
        }
        // console.log(a)
        // console.log(r)
        var res= []
        for (var i = 0; i < x; i++) {
            if(b[i] >=a[r]) res.push(i+1)
        }
        console.log(res.length)
        console.log(res.join(' '))
        // var res = []
        // for (var i = 0; i < x; i++) {
        //     if (i === 0) {
        //         if (a[i] >= max) res.push(a[i])
        //         continue
        //     }
        //     if (a[i] + sum[i - 1] >= max) res.push(a[i])
        // }

    })

}

function find(a, m) {
    var sum = 0
    for (var i = 0; i <= m; i++) {
        sum += a[i]
    }
    i = m + 1
    while (sum >= a[i]) {
        sum += a[i]
        i++
    }
    if (i === a.length) return true
    return false
}

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

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

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

		const b = a.slice();

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

		let mintokens = [];
		for (let i = 0, pr = 0; i < n; i++) {
			pr += a[i];
			if (i == n-1 || pr >= a[i+1]) {
				mintokens.push(a[i]);
			} else {
				mintokens.length = 0;
			}
		}

		mintokens = Math.min(...mintokens);
		const ans = [];
		for(let i = 0; i < n; i++) {
			if (b[i] >= mintokens)
				ans.push(i+1);
		}

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

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

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

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

		for (let i = 0; i < n; i++) {
			a[i] = [a[i], i+1];
		}

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

		const pr = [0];
		for (let i = 0; i < n; i++) {
			pr[i+1] = pr[i] + a[i][0];
		}

		const ans = [];
		for (let i = 0; i < n; i++) {
			if (i == n-1 || pr[i+1] >= a[i+1][0]) {
				ans.push(a[i][1]);
			} else {
				ans.length = 0;
			}
		}

		ans.sort((x, y) => x-y);
		console.log(ans.length);
		console.log(ans.join(' '));
	}
}

let lines = require('fs').readFileSync(global.FILE_DESCRIPTOR || 0).toString().split('\n');
let index = 0;
const readline = () => lines[index++] || '';

let n = +readline();
while (n--) {
  readline();
  let arr = readline().split(' ').map(i => +i);
  let map = {};
  let count = 0;
  arr.forEach(num => {
    if (!map[num]) map[num] = 0;
    map[num]++;
  })
  let values = Object.keys(map).map(item => +item);
  let min = 0
  let sum = 0;
  if (values.length > 1) {
    values.forEach((num, index) => {
      if (index === values.length - 1) return;
      let curr = map[num] * num;
      if (sum + curr < values[index + 1]) {
        min = num
      }
      sum += curr
    })
  }
  arr.forEach(num => count += num > min ? 1 : 0);
  console.log(count)
  console.log(arr.map((num, index) => num > min ? (index + 1) : 0).filter(item => item).join(' '))
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = new Array(N);
		for(var j = 0; j < N; j++){
			var v = nextInt();
			list[j] = {
				no : j,
				v : v,
				sum : v
			};
		}
		list.sort(function(a,b){
			return a.v - b.v;
		});
		for(var j = 1; j < N; j++){
			list[j].sum += list[j - 1].sum;
		}
		for(var j = N - 1; j >= 1; j--){
			if(list[j].v == list[j - 1].v){
				list[j - 1].sum = list[j].sum;
			}
		}
		var output = [list[N - 1].no + 1];
		for(var j = N - 2; j >= 0; j--){
			if(list[j].sum >= list[j + 1].v){
				output.push(list[j].no + 1);
			}else{
				break;
			}
		}
		//myerr(list);
		output.sort(function(a,b){
			return a - b;
		});
		myout(output.length);
		myout(myconv(output, 8));
	}
}

var row = readline().split(" ").map(function(x) { return parseInt(x); });
while(true) {
    var read = readline();
    if(read == undefined) break;
    var n = read.split(" ").map(function(x) { return parseInt(x); })[0];
    var arr = readline().split(" ").map(function(x) { return parseInt(x); });
    var sortedArr = [...arr];

    var compare = function(a, b) {
        return parseInt(a) - parseInt(b);
    }

    sortedArr.sort(compare);
    var result = [];
    var max = 0;
    var maxIdx = 0;
    var total = 0;

    for(var i = 0; i < n; i++) {
        total += sortedArr[i];
    }

    var previous = sortedArr[n - 1];

    for(var i = n - 1; i >= 0; i--) {
        //write("Total - Prev - Curr: " + total + " - " + previous + " - " + sortedArr[i] + "\n");
        if(i == n - 1 || sortedArr[i] != previous) {
            if(sortedArr[i] > total - sortedArr[i]) {
                if(sortedArr[0] != sortedArr[i]) {
                    previous = sortedArr[i];
                }
                break;
            } else {
                if(sortedArr[0] == sortedArr[i]) {
                    if(total >= previous)
                        previous = sortedArr[i];
                    else
                        break;
                }
            }
        }
        previous = sortedArr[i];
        total -= sortedArr[i];
        if(previous > total)
            break;
    }

    var arrResult = [];
    for(var i = 0; i < n; i++) {
        if(arr[i] >= previous) arrResult.push(i + 1);
    }
    write(arrResult.length + "\n");
    write(arrResult.sort(compare).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();

var height = []

function main() {
    var xx = Number(readline())
    Array(Number(xx)).fill(1).map((t, i) => {

        var x = parseInt(readline())
        var a = readline().split(' ').map((x, i) => {
            return parseInt(x)
        })
        var b = a.slice()
        a = a.sort((a, b) => a - b)

        var l = -1
        var m
        var r = x //Number.max integer
        while (r > l + 1) {

            m = Math.floor((l + r) / 2)
            // console.log(l, r,m)

            if (find(a, m)) r = m
            else l = m
        }
        // console.log(a)
        // console.log(r)
        var res= []
        for (var i = r; i < x; i++) {
            if(b[i] >=a[r]) res.push(i+1)
        }
        console.log(res.length)
        console.log(res.join(' '))
        // var res = []
        // for (var i = 0; i < x; i++) {
        //     if (i === 0) {
        //         if (a[i] >= max) res.push(a[i])
        //         continue
        //     }
        //     if (a[i] + sum[i - 1] >= max) res.push(a[i])
        // }

    })

}

function find(a, m) {
    var sum = 0
    for (var i = 0; i <= m; i++) {
        sum += a[i]
    }
    i = m + 1
    while (sum >= a[i]) {
        sum += a[i]
        i++
    }
    if (i === a.length) return true
    return false
}

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

var height = []

function main() {
    var xx = Number(readline())
    Array(Number(xx)).fill(1).map((t, i) => {

        var x = parseInt(readline())
        var a = readline().split(' ').map((x, i) => {
            return parseInt(x)
        })
        var b = a.slice()
        a = a.sort((a, b) => a - b)

        var l = -1
        var m
        var r = x //Number.max integer
        while (r > l + 1) {

            m = Math.floor((l + r) / 2)
            // console.log(l, r,m)

            if (find(a, m)) r = m
            else l = m
        }
        // console.log(a)
        // console.log(r)
        var res= []
        for (var i = r; i < x; i++) {
            res.push(a[i])
        }
        console.log(res.length)
        console.log(res.join(' '))
        // var res = []
        // for (var i = 0; i < x; i++) {
        //     if (i === 0) {
        //         if (a[i] >= max) res.push(a[i])
        //         continue
        //     }
        //     if (a[i] + sum[i - 1] >= max) res.push(a[i])
        // }

    })

}

function find(a, m) {
    var sum = 0
    for (var i = 0; i <= m; i++) {
        sum += a[i]
    }
    i = m + 1
    while (sum >= a[i]) {
        sum += a[i]
        i++
    }
    if (i === a.length) return true
    return false
}

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

var height = []

function main() {
    var xx = Number(readline())
    Array(Number(xx)).fill(1).map((t, i) => {

        var x = parseInt(readline())
        var a = readline().split(' ').map((x, i) => {
            return parseInt(x)
        })
        var b = a.slice()
        a = a.sort((a, b) => a - b)

        var l = -1
        var m
        var r = x //Number.max integer
        while (r > l + 1) {

            m = Math.floor((l + r) / 2)
            // console.log(l, r,m)

            if (find(a, m)) r = m
            else l = m
        }
        // console.log(a)
        // console.log(r)
        var res= []
        for (var i = 0; i < x; i++) {
            if(b[i] >=a[r]) res.push(b[i])
        }
        console.log(res.length)
        console.log(res.join(' '))
        // var res = []
        // for (var i = 0; i < x; i++) {
        //     if (i === 0) {
        //         if (a[i] >= max) res.push(a[i])
        //         continue
        //     }
        //     if (a[i] + sum[i - 1] >= max) res.push(a[i])
        // }

    })

}

function find(a, m) {
    var sum = 0
    for (var i = 0; i <= m; i++) {
        sum += a[i]
    }
    i = m + 1
    while (sum >= a[i]) {
        sum += a[i]
        i++
    }
    if (i === a.length) return true
    return false
}

var row = readline().split(" ").map(function(x) { return parseInt(x); });
while(true) {
    var read = readline();
    if(read == undefined) break;
    var n = read.split(" ").map(function(x) { return parseInt(x); })[0];
    var arr = readline().split(" ").map(function(x) { return parseInt(x); });
    var sortedArr = [...arr];

    var compare = function(a, b) {
        return parseInt(a) - parseInt(b);
    }

    sortedArr.sort(compare);
    var result = [];
    var max = 0;
    var maxIdx = 0;
    var total = 0;

    for(var i = 0; i < n; i++) {
        total += sortedArr[i];
    }

    var previous = sortedArr[n - 1];

    for(var i = n - 1; i >= 0; i--) {
        //write("Total - Prev - Curr: " + total + " - " + previous + " - " + sortedArr[i] + "\n");
        if(i == n - 1 || sortedArr[i] != previous) {
            if(sortedArr[i] > total - sortedArr[i]) {
                if(sortedArr[0] != sortedArr[i]) {
                    previous = sortedArr[i];
                }
                break;
            } else {
                if(sortedArr[0] == sortedArr[i]) {
                    if(total >= previous)
                        previous = sortedArr[i];
                    else
                        break;
                }
            }
        }
        previous = sortedArr[i];
        total -= sortedArr[i];
        if(previous > total)
            break;
    }

    var arrResult = [];
    for(var i = 0; i < n; i++) {
        if(arr[i] >= previous) arrResult.push(i + 1);
    }
    write(arrResult.length + "\n");
    write(arrResult.sort().join(" ") + "\n");
}

var row = readline().split(" ").map(function(x) { return parseInt(x); });
while(true) {
    var read = readline();
    if(read == undefined) break;
    var n = read.split(" ").map(function(x) { return parseInt(x); })[0];
    var arr = readline().split(" ").map(function(x) { return parseInt(x); });
    var sortedArr = [...arr];

    var compare = function(a, b) {
        return parseInt(a) - parseInt(b);
    }

    sortedArr.sort(compare);
    var result = [];
    var max = 0;
    var maxIdx = 0;
    var total = 0;

    for(var i = 0; i < n; i++) {
        total += sortedArr[i];
    }

    var previous = sortedArr[n - 1];
    for(var i = n - 1; i >= 0; i--) {
        if(i == n - 1 || sortedArr[i] != previous) {
            if(sortedArr[i] > total - sortedArr[i]) {
                if(sortedArr[0] != sortedArr[i]) {
                    previous = sortedArr[i];
                }
                break;
            } else {
                if(sortedArr[0] == sortedArr[i]) {
                    if(total >= previous)
                        previous = sortedArr[i];
                    else
                        break;
                }
            }
        }
        previous = sortedArr[i];
        total -= sortedArr[i];
    }

    var arrResult = [];
    for(var i = 0; i < n; i++) {
        if(arr[i] >= previous) arrResult.push(i + 1);
    }
    write(arrResult.length + "\n");
    write(arrResult.sort().join(" ") + "\n");
}

var row = readline().split(" ").map(function(x) { return parseInt(x); });
while(true) {
    var read = readline();
    if(read == undefined) break;
    var n = read.split(" ").map(function(x) { return parseInt(x); })[0];
    var arr = readline().split(" ").map(function(x) { return parseInt(x); });
    var sortedArr = [...arr];
    sortedArr.sort();
    var result = [];
    var max = 0;
    var maxIdx = 0;
    var total = 0;

    for(var i = 0; i < n; i++) {
        total += sortedArr[i];
    }

    var previous = sortedArr[n - 1];
    for(var i = n - 1; i >= 0; i--) {
        if(i == n - 1 || sortedArr[i] != previous) {
            if(sortedArr[i] > total - sortedArr[i]) {
                if(sortedArr[0] != sortedArr[i]) {
                    previous = sortedArr[i];
                }
                break;
            } else {
                if(sortedArr[0] == sortedArr[i]) {
                    if(total >= previous)
                        previous = sortedArr[i];
                    else
                        break;
                }
            }
        }
        previous = sortedArr[i];
        total -= sortedArr[i];
    }

    var arrResult = [];
    for(var i = 0; i < n; i++) {
        if(arr[i] >= previous) arrResult.push(i + 1);
    }
    write(arrResult.length + "\n");
    write(arrResult.sort().join(" ") + "\n");
}

var row = readline().split(" ").map(function(x) { return parseInt(x); });
while(true) {
    var read = readline();
    if(read == undefined) break;
    var n = read.split(" ").map(function(x) { return parseInt(x); })[0];
    var arr = readline().split(" ").map(function(x) { return parseInt(x); });
    var sortedArr = [...arr];
    sortedArr.sort();
    var result = [];
    var max = 0;
    var maxIdx = 0;
    var total = 0;

    for(var i = 0; i < n; i++) {
        total += sortedArr[i];
    }

    var previous = sortedArr[n - 1];
    for(var i = n - 1; i >= 0; i--) {
        if((i == n - 1 || sortedArr[i] != previous) && sortedArr[i] > total - sortedArr[i]) {
            previous = sortedArr[i];
            break;
        }
        previous = sortedArr[i];
        total -= sortedArr[i];
    }

    var arrResult = [];
    for(var i = 0; i < n; i++) {
        if(arr[i] >= previous) arrResult.push(i + 1);
    }
    write(arrResult.length + "\n");
    write(arrResult.sort().join(" ") + "\n");
}

var row = readline().split(" ").map(function(x) { return parseInt(x); });
while(true) {
    var read = readline();
    if(read == undefined) break;
    var n = read.split(" ").map(function(x) { return parseInt(x); })[0];
    var arr = readline().split(" ").map(function(x) { return parseInt(x); });
    var sortedArr = [...arr];
    sortedArr.sort();
    var result = [];
    var max = 0;
    var maxIdx = 0;
    var total = 0;

    for(var i = 0; i < n; i++) {
        total += sortedArr[i];
    }

    var previous = sortedArr[n - 1];
    for(var i = n - 1; i >= 0; i--) {
        if((i == n - 1 || sortedArr[i] != previous) && sortedArr[i] > total - sortedArr[i]) {
            previous = sortedArr[i];
            break;
        }
        previous = sortedArr[i];
        total -= sortedArr[i];
    }

    var arrResult = [];
    for(var i = 0; i < n; i++) {
        if(arr[i] >= previous) arrResult.push(i + 1);
    }

    write(arrResult.sort().join(" ") + "\n");
}


function bundle (x, y, x2, y2) {
    return (x + ',' + y + ',' + x2 + ',' + y2);
}
function solve() {
    var str = readline().split('');
    var s = new Set([]);
    var x = 0, y = 0;
    var ans = 0;
    str.forEach(a => {
        var nx = x, ny = y;
        switch(a) {
            case 'S':
                ny--; break;
            case 'N':
                ny++; break;
            case 'W':
                nx--; break;
            default:
                nx++;
        }
        // s.forEach(x => {print(x);})
        ans += (s.has(bundle(x, y, nx, ny)) ? 1 : 5);
        s.add(bundle(x, y, nx, ny));
        s.add(bundle(nx, ny, x, y));
        x = nx, y = ny;
    });
    print(ans);
}

var n = parseInt(readline());
for (var i = 0; i < n; ++i) solve();

function getHaah(x, y) {
    return x*300000+y;
}

var t = Number(readline());
while(t--) {
    var v = readline();
    var se1 = new Set();
    var se2 = new Set();

    var curx = 100000, cury = 100000, ans = 0;
    for(var i in v) {
        var nx = curx, ny = cury;

        if(v[i] === "N") ny++;
        else if(v[i] === "S") ny--;
        else if(v[i] === 'E') nx++;
        else nx--;

        var h = getHaah(Math.min(curx, nx), Math.min(cury, ny));
        if(v[i] === "N" || v[i] === "S") {
            if(se1.has(h)) ans += 1;
            else ans += 5;

            se1.add(h);
        }
        else {
            if(se2.has(h)) ans += 1;
            else ans += 5;

            se2.add(h);
        }

        curx = nx, cury = ny;
    }

    print(ans);
}

'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++];
}
/**
    3
1 3
100000 100000
2 2

**/

function main() {
    var range = readline();

    for(var r=0;r<range;r++) {

        let directions = readline().split("");
        let pathCovered = {};
        let count = 0;
        let x = 0, y=0;
        let cx = 0, cy = 0;

        for(let i=0;i<directions.length;i++) {
            cx = x;
            cy = y;

            switch(directions[i]) {
                case "N":
                    cy+=1;
                    break;
                case "S":
                    cy-=1;
                    break;
                case "W":
                    cx+=1;
                    break;
                default:
                    cx-=1;
            }

            let d1 = x + "" + y + "" + cx + "" + cy;
            let d2 = cx + "" + cy + "" + x + "" + y;

            if(pathCovered[d1] || pathCovered[d2]) {
                count = count + 1;
            } else {
                pathCovered[d1] = d1;
                pathCovered[d2] = d2;
                count = count + 5;
            }

            x = cx;
            y = cy;
        }

        console.log(count);

    }
}

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

var N = null

function textify(ab,cd) {
    let abFirst = ab[0] < cd[0]
    if (ab[0] == cd[0])
        abFirst = ab[1] < cd[1]
    return abFirst ? (ab.join(",")+","+cd.join(",")) : (cd.join(",")+","+ab.join(","))
}

function move(xy,dir) {
    let sgn = -1
    switch(dir) {
        case "E":
            sgn = 1
        case "W":
            xy[0] += sgn
            break
        case "N":
            sgn = 1
        case "S":
            xy[1] += sgn
            break
    }
}

function loop(line) {

    if (N == null) return N = Number(line)
    let t = 0,
        coords = new Set(),
        prevCord = [0,0],
        currCord = [0,0]
    for (let i=0;i<line.length;i++) {
        move(currCord,line[i])
        let currPath = textify(prevCord, currCord)
        t += coords.has(currPath) ? 1 : 5
        if (!coords.has(currPath))
            coords.add(currPath)
        prevCord[0] = currCord[0]
        prevCord[1] = currCord[1]
    }
    console.log(t)

    if (--N == 0)
        rl.close()

}

rl.on("line", line => loop(line))

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

const rethreads = [
    /(W+)(E+)/g,
    /(E+)(W+)/g,
    /(N+)(S+)/g,
    /(S+)(N+)/g
],
max = 10**5

var N = null

function linear(xy) {
    return xy[0] + max*xy[1]
}

function move(xy,dir) {
    let sgn = -1
    switch(dir) {
        case "E":
            sgn = 1
        case "W":
            xy[0] += sgn
            break
        case "N":
            sgn = 1
        case "S":
            xy[1] += sgn
            break
    }
    return xy.join(",")
}

function loop(line) {

    if (N == null) return N = Number(line)
    /*
    let prevLen = -1
    while (prevLen != line.length) {
        for (let i=0; i<4; i++)
            line = line.replace(rethreads[i], (_,a,b)=>{
                const isA = a.length < b.length
                const len = isA ? a.length : b.length
                t += 6*len
                return (isA ? b.substr(len) : a.substr(len)) + (a.toLowerCase() + len)
            })
    }
    */
    let t = 0,
        coords = new Set(["0,0"]),
        currCord = [0,0],
        currXY = "0,0",
        nextXY = ""
    for (let i=0;i<line.length;i++) {
        nextXY = move(currCord,line[i])
        t += (coords.has(nextXY) && coords.has(currXY)) ? 1 : 5
        if (!(nextXY in coords))
            coords.add(nextXY)
        currXY = nextXY
    }
    console.log(t)

    if (--N == 0)
        rl.close()

}

rl.on("line", line => loop(line))

'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++];
}
/**
    3
1 3
100000 100000
2 2

**/

function main() {
    var range = readline();

    for(var r=0;r<range;r++) {
        const direction = {
            'N': 'S',
            'S': 'N',
            'E': 'W',
            'W': 'E'
        }

        let directions = readline().split("");
        let pathCovered = [];
        let count = 0;

        for(let i=0;i<directions.length;i++) {
            if(!pathCovered.length) {
                count = count + 5;
                pathCovered.push(direction[directions[i]]);
                continue;
            }

            let d = directions[i];
            let path1 = pathCovered.pop();
            let path2 = pathCovered.pop();

            if(path1 === d || path2 === d) {
                count = count + 1;
                path2? pathCovered.push(path2) : '';
            } else {
                count = count + 5;
                pathCovered.push(path1);
                pathCovered.push(path2);
                pathCovered.push(direction[directions[i]]);
            }
        }

        console.log(count);

    }
}

'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++];
}
/**
    3
1 3
100000 100000
2 2

**/

function main() {
    var range = readline();

    for(var r=0;r<range;r++) {
        const direction = {
            'N': 'S',
            'S': 'N',
            'E': 'W',
            'W': 'E'
        }

        let directions = readline().split("");
        let pathCovered = [];
        let count = 0;

        for(let i=0;i<directions.length;i++) {
            if(!pathCovered.length) {
                count = count + 5;
                pathCovered.push(direction[directions[i]]);
                continue;
            }

            let d = directions[i];
            let path1 = pathCovered.pop();
            let path2 = pathCovered.pop();

            if(path1 === d || path2 === d) {
                count = count + 1;
                pathCovered.push(path1);
            } else {
                count = count + 5;
                pathCovered.push(direction[directions[i]]);
            }
        }

        console.log(count);

    }
}

'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++];
}
/**
    3
1 3
100000 100000
2 2

**/

function main() {
    var range = readline();

    for(var r=0;r<range;r++) {
        const direction = {
            'N': 'S',
            'S': 'N',
            'E': 'W',
            'W': 'E'
        }

        let directions = readline().split("");
        let pathCovered = [];
        let count = 0;

        for(let i=0;i<directions.length;i++) {
            if(!pathCovered.length) {
                count = count + 5;
                pathCovered.push(direction[directions[i]]);
                continue;
            }

            let d = directions[i];
            let path1 = pathCovered.pop();
            let path2 = pathCovered.pop();

            if(path1 === d || path2 === d) {
                count = count + 1;
                pathCovered.push(path1);
                pathCovered.push(path2);
                pathCovered.push(direction[directions[i]]);

            } else {
                count = count + 5;
                pathCovered.push(path1);
                pathCovered.push(path2);
                pathCovered.push(direction[directions[i]]);
            }
        }

        console.log(count);

    }
}

'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++];
}
/**
    3
1 3
100000 100000
2 2

**/

function main() {
    var range = readline();

    for(var r=0;r<range;r++) {
        const direction = {
            'N': 'S',
            'S': 'N',
            'E': 'W',
            'W': 'E'
        }

        let directions = readline().split("");
        let pathCovered = [];
        let count = 0;

        for(let i=0;i<directions.length;i++) {
            if(!pathCovered.length) {
                count = count + 5;
                pathCovered.push(direction[directions[i]]);
                continue;
            }

            let d = directions[i];
            let path1 = pathCovered.pop();
            let path2 = pathCovered.pop();

            if(path1 === d || path2 === d) {
                count = count + 1;
                path2? pathCovered.push(path2) : '';
                pathCovered.push(direction[directions[i]]);

            } else {
                count = count + 5;
                pathCovered.push(path1);
                pathCovered.push(path2);
                pathCovered.push(direction[directions[i]]);
            }
        }

        console.log(count);

    }
}

'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++];
}
/**
    3
1 3
100000 100000
2 2

**/

function main() {
    var range = readline();

    for(var r=0;r<range;r++) {
        const direction = {
            'N': 'S',
            'S': 'N',
            'E': 'W',
            'W': 'E'
        }

        let directions = readline().split("");
        let pathCovered = [];
        let count = 0;

        for(let i=0;i<directions.length;i++) {
            if(!pathCovered.length) {
                count = count + 5;
                pathCovered.push(direction[directions[i]]);
                continue;
            }

            let d = directions[i];
            let path1 = pathCovered.pop();
            let path2 = pathCovered.pop();

            if(path1 === d || path2 === d) {
                count = count + 1;
                pathCovered.push(path2);
            } else {
                count = count + 5;
                pathCovered.push(direction[directions[i]]);
            }
        }

        console.log(count);

    }
}


function solve() {
   var n = Number(read());
   var a = read().split(' ').map(function(x, i) {
      var x1 = Math.abs(Number(x));
      if (i & 1) {
         x1 = -x1;
      }
      return x1;
   });
   for (var i = 1; i < n - 1; i++) {
      if (a[i - 1] < a[i] && a[i] < a[i + 1] || a[i - 1] > a[i] && a[i] > a[i + 1]) {
         a[i] = -a[i];
      }
   }
   write(a.join(' '));
}

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

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;
   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();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

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

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (inputStd) => {
  inputString += inputStd;
});
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--) {
    let len = +readLine();
    const nums = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    let i = 0;
    while (i < len) {
      if (i % 2 === 0) nums[i] = Math.abs(nums[i]);
      else nums[i] = -Math.abs(nums[i]);
      i++;
    }
    console.log(nums.join(" "));
  }
}