A championship is held in Berland, in which $$$n$$$ players participate. The player with the number $$$i$$$ has $$$a_i$$$ ($$$a_i \ge 1$$$) tokens.The championship consists of $$$n-1$$$ games, which are played according to the following rules:  in each game, two random players with non-zero tokens are selected;  the player with more tokens is considered the winner of the game (in case of a tie, the winner is chosen randomly);  the winning player takes all of the loser's tokens; The last player with non-zero tokens is the winner of the championship.All random decisions that are made during the championship are made equally probable and independently.For example, if $$$n=4$$$, $$$a = [1, 2, 4, 3]$$$, then one of the options for the game (there could be other options) is:   during the first game, the first and fourth players were selected. The fourth player has more tokens, so he takes the first player's tokens. Now $$$a = [0, 2, 4, 4]$$$;  during the second game, the fourth and third players were selected. They have the same number of tokens, but in a random way, the third player is the winner. Now $$$a = [0, 2, 8, 0]$$$;  during the third game, the second and third players were selected. The third player has more tokens, so he takes the second player's tokens. Now $$$a = [0, 0, 10, 0]$$$;  the third player is declared the winner of the championship. Championship winners will receive personalized prizes. Therefore, the judges want to know in advance which players have a chance of winning, i.e have a non-zero probability of winning the championship. You have been asked to find all such players.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case consists of one positive integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of players in the championship. The second line of each test case contains $$$n$$$ positive integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the number of tokens the players have. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print the number of players who have a nonzero probability of winning the championship. On the next line print the numbers of these players in increasing order. Players are numbered starting from one in the order in which they appear in the input.

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


Skier rides on a snowy field. Its movements can be described by a string of characters 'S', 'N', 'W', 'E' (which correspond to $$$1$$$ meter movement in the south, north, west or east direction respectively).It is known that if he moves along a previously unvisited segment of a path (i.e. this segment of the path is visited the first time), then the time of such movement is $$$5$$$ seconds. If he rolls along previously visited segment of a path (i.e., this segment of the path has been covered by his path before), then it takes $$$1$$$ second.Find the skier's time to roll all the path.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each set is given by one nonempty string of the characters 'S', 'N', 'W', 'E'. The length of the string does not exceed $$$10^5$$$ characters. The sum of the lengths of $$$t$$$ given lines over all test cases in the input does not exceed $$$10^5$$$.

For each test case, print the desired path time in seconds.

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

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

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

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

    }
}


Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will start painting squares one by one from left to right, starting from the square number 1 and some arbitrary color. If the square was painted in color x, then the next square will be painted in color x + 1. In case of x = n, next square is painted in color 1. If there is no more paint of the color Vika wants to use now, then she stops.Square is always painted in only one color, and it takes exactly 1 liter of paint. Your task is to calculate the maximum number of squares that might be painted, if Vika chooses right color to paint the first square.

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that Vika has.

The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.

NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5.

n = ~~readline()
p = readline().split(' ').map(Number)
min = max = -1
for(i in p) {
  if(min == -1 || min > p[i]) min = p[i]
  if(max == -1 || max < p[i]) max = p[i]
}
for(i in p) {
  p[i] -= min
}
m = min*p.length
seq = 0
maxseq = -1
for(i=0; i<=n*2;i++) {
  if(p[i%n]) seq++
  else {
    if(maxseq == -1 || maxseq < seq) maxseq = seq
    seq = 0
  }
}
print(min*p.length + maxseq)

n = ~~readline()
p = readline().split(' ').map(Number)
min = max = -1
for(i in p) {
  if(min == -1 || min > p[i]) min = p[i]
  if(max == -1 || max < p[i]) max = p[i]
}
for(i in p) {
  p[i] -= min
}
m = min*p.length
seq = 1
maxseq = -1
for(i=0; i<=n*2;i++) {
  if(p[i%n]) seq++
  else {
    if(maxseq == -1 || maxseq < seq) maxseq = seq
    seq = 0
  }
}
print(min*p.length + maxseq)


Polycarp likes numbers that are divisible by 3.He has a huge number $$$s$$$. Polycarp wants to cut from it the maximum number of numbers that are divisible by $$$3$$$. To do this, he makes an arbitrary number of vertical cuts between pairs of adjacent digits. As a result, after $$$m$$$ such cuts, there will be $$$m+1$$$ parts in total. Polycarp analyzes each of the obtained numbers and finds the number of those that are divisible by $$$3$$$.For example, if the original number is $$$s=3121$$$, then Polycarp can cut it into three parts with two cuts: $$$3|1|21$$$. As a result, he will get two numbers that are divisible by $$$3$$$.Polycarp can make an arbitrary number of vertical cuts, where each cut is made between a pair of adjacent digits. The resulting numbers cannot contain extra leading zeroes (that is, the number can begin with 0 if and only if this number is exactly one character '0'). For example, 007, 01 and 00099 are not valid numbers, but 90, 0 and 10001 are valid.What is the maximum number of numbers divisible by $$$3$$$ that Polycarp can obtain?

The first line of the input contains a positive integer $$$s$$$. The number of digits of the number $$$s$$$ is between $$$1$$$ and $$$2\cdot10^5$$$, inclusive. The first (leftmost) digit is not equal to 0.

Print the maximum number of numbers divisible by $$$3$$$ that Polycarp can get by making vertical cuts in the given number $$$s$$$.

NoteIn the first example, an example set of optimal cuts on the number is 3|1|21.In the second example, you do not need to make any cuts. The specified number 6 forms one number that is divisible by $$$3$$$.In the third example, cuts must be made between each pair of digits. As a result, Polycarp gets one digit 1 and $$$33$$$ digits 0. Each of the $$$33$$$ digits 0 forms a number that is divisible by $$$3$$$.In the fourth example, an example set of optimal cuts is 2|0|1|9|201|81. The numbers $$$0$$$, $$$9$$$, $$$201$$$ and $$$81$$$ are divisible by $$$3$$$.

s=readline()
n=s.length
res=0
a=new Array(n)
for (i=0;i<n;i++)
{
    a[i]=s[i]%3
    if (a[i]==0)
    {
        ++res
    }
}
a=a.join('').split('0')
n=a.length
for (i=0;i<n;i++)
{
    m=a[i].length
    sum=0
    len=0
    for (j=0;j<m;j++)
    {
        sum+=(+a[i][j])
        ++len
        if (sum%3==0)
        {
            res++
            len=0
        }
        if (len==3)
        {
            res++
            sum=0
            len=0
        }
    }
}
print(res)


You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$n$$$ is odd. You are allowed to flip the sign of some (possibly all or none) of them. You wish to perform these flips in such a way that the following conditions hold:  At least $$$\frac{n - 1}{2}$$$ of the adjacent differences $$$a_{i + 1} - a_i$$$ for $$$i = 1, 2, \dots, n - 1$$$ are greater than or equal to $$$0$$$.  At least $$$\frac{n - 1}{2}$$$ of the adjacent differences $$$a_{i + 1} - a_i$$$ for $$$i = 1, 2, \dots, n - 1$$$ are less than or equal to $$$0$$$. Find any valid way to flip the signs. It can be shown that under the given constraints, there always exists at least one choice of signs to flip that satisfies the required condition. If there are several solutions, you can find any of them.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 500$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$3 \le n \le 99$$$, $$$n$$$ is odd)  — the number of integers given to you. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$)  — the numbers themselves. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10000$$$.

For each test case, print $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$, corresponding to the integers after flipping signs. $$$b_i$$$ has to be equal to either $$$a_i$$$ or $$$-a_i$$$, and of the adjacent differences $$$b_{i + 1} - b_i$$$ for $$$i = 1, \dots, n - 1$$$, at least $$$\frac{n - 1}{2}$$$ should be non-negative and at least $$$\frac{n - 1}{2}$$$ should be non-positive. It can be shown that under the given constraints, there always exists at least one choice of signs to flip that satisfies the required condition. If there are several solutions, you can find any of them.

NoteIn the first test case, the difference $$$(-4) - (-2) = -2$$$ is non-positive, while the difference $$$3 - (-4) = 7$$$ is non-negative.In the second test case, we don't have to flip any signs. All $$$4$$$ differences are equal to $$$0$$$, which is both non-positive and non-negative.In the third test case, $$$7 - (-4)$$$ and $$$4 - (-6)$$$ are non-negative, while $$$(-4) - (-2)$$$ and $$$(-6) - 7$$$ are non-positive.

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

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


Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer $$$x$$$ with $$$p$$$ zeros appended to its end.Now Monocarp asks you to compare these two numbers. Can you help him?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$x_1$$$ and $$$p_1$$$ ($$$1 \le x_1 \le 10^6; 0 \le p_1 \le 10^6$$$) — the description of the first number. The second line of each testcase contains two integers $$$x_2$$$ and $$$p_2$$$ ($$$1 \le x_2 \le 10^6; 0 \le p_2 \le 10^6$$$) — the description of the second number.

For each testcase print the result of the comparison of the given two numbers. If the first number is smaller than the second one, print '<'. If the first number is greater than the second one, print '>'. If they are equal, print '='.

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--) {
		let [x1, p1] = rna();
		let [x2, p2] = rna();

		const mn = Math.min(p1, p2);
		p1 -= mn;
		p2 -= mn;

		while (x1 <= 1e6 && p1) { x1 *= 10; p1--; }
		while (x2 <= 1e6 && p2) { x2 *= 10; p2--; }
		let ans = x1 - x2;

		if (ans <  0) console.log('<');
		if (ans == 0) console.log('=');
		if (ans >  0) console.log('>');
	}
}

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--) {
		let [x1, p1] = rna();
		let [x2, p2] = rna();

		while (x1 <= 1e6-1 && p1) { x1 *= 10; p1--; }
		while (x2 <= 1e6-1 && p2) { x2 *= 10; p2--; }
		if (p1 > p2) x1 *= 10;
		if (p2 > p1) x2 *= 10;
		let ans = x1 - x2;

		if (ans <  0) console.log('<');
		if (ans == 0) console.log('=');
		if (ans >  0) console.log('>');
	}
}

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--) {
		let [x1, p1] = rna();
		let [x2, p2] = rna();

		let ans;
		if (String(x1).length + p1 < String(x2).length + p2)
			ans = -1;
		else if (String(x1).length + p1 > String(x2).length + p2)
			ans = 1;
		else {
			while (x1 <= 1e6-1) x1 *= 10;
			while (x2 <= 1e6-1) x2 *= 10;
			ans = x1 - x2;
		}

		if (ans <  0) console.log('<');
		if (ans == 0) console.log('=');
		if (ans >  0) console.log('>');
	}
}

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

const MX = 1e6 + 7;

function main () {
	let T = rn();
	while (T--) {
		let [x1, p1] = rna();
		let [x2, p2] = rna();

		let ans = x1 * Math.pow(10, Math.min(Math.max(p1 - p2, 0), 7)) -
	  		      x2 * Math.pow(10, Math.min(Math.max(p2 - p1, 0), 7));

		ans = ans == 0 ? '=' : (ans > 0 ? '>' : '<');
		console.log(ans);
	}
}

/**
 * https://codeforces.com/problemset/problem/1613/A
 */

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

    const input = [];
    return new Promise((resolve) => {
        readLine.on('close', () => resolve(input));
        readLine.on('line', (line) => input.push(line));
    });
}

/**
 *
 * @param {Array<number>} data
 * @param {number} testCount
 * @param {number} linesPerCase
 * @returns {Array<string>}
 */
function* splitTestCase(data, testCount, linesPerCase) {
    for (let i = 0, ii = 0; i < testCount; i++, ii = i * linesPerCase) {
        yield data.slice(ii, ii + linesPerCase);
    }
}

/**
 *
 * @param {Array<string>} arr
 * @returns {number}
 */
function len(arr) {
    return arr[0].length + Number.parseInt(arr[1]) || 0;
}

/**
 *
 * @param {number} x1
 * @param {number} x2
 * @returns {string | undefined}
 */
function compare(x1, x2) {
    if (x1 > x2) { return '>'; }
    if (x1 < x2) { return '<'; }

    return;
}

/**
 *
 * @param {Array<string>} input1
 * @param {Array<string>} input2
 */
function run(input1, input2) {
    // Early escape
    if (input1 === input2) { return '='; }

    let result = compare(len(input1), len(input2));
    if (result) { return result; }

    // Inputs have the same length, normalize length of meaningful part and compare
    const normalizedLen = Math.max(input1[0].length, input2[0].length);
    result = compare(Number.parseInt(input1[0].padEnd(normalizedLen, 0)), Number.parseInt(input2[0].padEnd(normalizedLen, 0)));
    if (result) { return result; }

    return '=';
}

nodeJSReader().then(([
    testCount,
    ...data
]
) => {
    for (const testCase of splitTestCase(data, testCount, 2)) {
        console.log(run(testCase[0].split(' '), testCase[1].split(' ')));
    }
});

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 [x1, p1] = lines[l++].trim().split(' ')
        const [x2, p2] = lines[l++].trim().split(' ')
        output[i] = solve(x1, p1, x2, p2)
    }
    console.log(output.join('\n'))
// })()
})

function solve(x1, p1, x2, p2) {
    p1 = +p1
    p2 = +p2
    if (x1.length + p1 > x2.length + p2) return '>'
    if (x1.length + p1 < x2.length + p2) return '<'

    const min = Math.min(p1, p2)
    p1 -= min
    p2 -= min
    let i = 0
    let j = 0
    while (i < p1 + x1.length && j < p2 + x2.length) {
        const a = i < x1.length ? +x1[i] : 0
        const b = j < x2.length ? +x2[j] : 0
        // console.log('sb', a, b)
        if (a < b) return '<'
        if (a > b) return '>'
        i++
        j++
    }
    return '='
}

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

let inputString = '';

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

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

    main(inputString);
});

function log(message){
    if(process.env.NODE_ENV === "debug"){
        console.log(message);
    }
}

function main(fileContents) {//input lines as an array
    // console.log(fileContents);
    fileContents.splice(0,1);

    for(let i = 0; i< fileContents.length-1; i+=2){
        const row1 = fileContents[i].split(" ");
        const num1base = row1[0]/Math.pow(10,row1[0].length-1)
        const num1pow = row1[0].length-1+parseInt(row1[1])

        const row2 = fileContents[i+1].split(" ");
        const num2base = row2[0]/Math.pow(10,row2[0].length-1)
        const num2pow = row2[0].length-1+parseInt(row2[1])

        // console.log(num1base,num1pow , num2base, num2pow)

        if(num1pow > num2pow){
            console.log(">")
        }else if(num1pow < num2pow){
            console.log("<")
        }else{
           if(num1base > num2base){
               console.log(">")
           }else if(num1base < num2base){
               console.log("<")
           }else{
               console.log("=")
           }
        }
    }

}

var pairsCount = parseInt(readline());

var results = [];

function compareNumbers(n1, n2) {
    n1 = parseInt(n1);
    n2 = parseInt(n2);
    if (n1 < n2) return '<';
    if (n1 > n2) return '>';
    return '=';
}

function compareCharNumbers(n1, n2) {
    n1 = String(n1);
    n2 = String(n2);
    for (var i = 0; i < n1.length; i++){
        var compareRes = compareNumbers(n1[i], n2[i]);
        if (compareRes !== '=') return compareRes;
    }

    return '=';
}

function addZeroesToNumber(str, zeroCount) {
    var i = zeroCount;
    var res = str + '';
    while (i > 0) {
        res += '0';
        i--;
    }
    return parseInt(res);
}

function getReadLineArray() {
    return readline().toString().trim().split(" ");
}

function getNumber(arr1, arr2, p_diff) {
    return arr1[1] > arr2[1] ? addZeroesToNumber(arr1[0], p_diff) : parseInt(arr1[0]);
}

var i = 0;
while (i < pairsCount) {
    var arr1 = getReadLineArray();
    var arr2 = getReadLineArray();

    var digs1 = arr1[0] === '0' ? 0 : (arr1[0].length + parseInt(arr1[1]));
    var digs2 = arr2[0] === '0' ? 0 : (arr2[0].length + parseInt(arr2[1]));

    if (digs1 === digs2) {
        var p_diff = Math.abs(arr1[1] - arr2[1]);
        var n1 = addZeroesToNumber(arr1[0], arr1[1] > arr2[1] ? p_diff : 0);
        var n2 = addZeroesToNumber(arr2[0], arr2[1] > arr1[1] ? p_diff : 0);
        results.push(compareCharNumbers(n1, n2));
    } else results.push(compareNumbers(digs1, digs2));
    i++;
}

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

var pairsCount = parseInt(readline());

var results = [];

function compareNumbers(n1, n2) {
    n1 = parseInt(n1);
    n2 = parseInt(n2);
    if (n1 < n2) return '<';
    if (n1 > n2) return '>';
    return '=';
}

function compareCharNumbers(n1, n2) {
    n1 = String(n1);
    n2 = String(n2);
    for (var i = 0; i < n1.length; i++){
        var compareRes = compareNumbers(n1[i], n2[i]);
        if (compareRes !== '=') return compareRes;
    }

    return '=';
}

function addZeroesToNumber(str, zeroCount) {
    // if (zeroCount === 0 || zeroCount === '0') {
    //     return parseInt(str);
    // }

    var i = zeroCount;
    var res = str + '';
    while (i > 0) {
        res += '0';
        i--;
    }
    return parseInt(res);
}

function getReadLineArray() {
    return readline().toString().trim().split(" ");
}

function getNumber(arr1, arr2, p_diff) {
    return arr1[1] > arr2[1] ? addZeroesToNumber(arr1[0], p_diff) : parseInt(arr1[0]);
}

var i = 0;
while (i < pairsCount) {
    var arr1 = getReadLineArray();
    var arr2 = getReadLineArray();

    var digs1 = arr1[0] === '0' ? 0 : (arr1[0].length + parseInt(arr1[1]));
    var digs2 = arr2[0] === '0' ? 0 : (arr2[0].length + parseInt(arr2[1]));

    if (digs1 === digs2) {
        var p_diff = Math.abs(arr1[1] - arr2[1]);
        var n1 = addZeroesToNumber(arr1[0], arr1[1] > arr2[1] ? p_diff : 0);
        var n2 = addZeroesToNumber(arr2[0], arr2[1] > arr1[1] ? p_diff : 0);
        results.push(compareCharNumbers(n1, n2));
    } else results.push(compareNumbers(digs1, digs2));
    i++;
}

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

var t = +readline();

while(t--) {
    var d1 = readline().split(' ');
    var d2 = readline().split(' ');
    var a = d1[0], b = d2[0];
    var ans = "=";

    var len1 = d1[0].length + Number(d1[1]);
    var len2 = d2[0].length + Number(d2[1]);

    if(len1 === len2) {
        a += "0".repeat(Math.max(0, b.length - a.length));
        b += "0".repeat(Math.max(0, a.length - b.length));
        ans = +a > +b ?  ">" : +a < +b ? "<" : "=";
    } else if (len1 > len2) {
        ans = ">";
    } else {
        ans = "<";
    }

    print(ans);
}

var t = parseInt(readline());

  while (t--) {
    var input1 = readline().split(" ");
    var input2 = readline().split(" ");

    var x1 = parseInt(input1[0]);
    var p1 = parseInt(input1[1]);

    var x2 = parseInt(input2[0]);
    var p2 = parseInt(input2[1]);

    var m = Math.min(p1, p2);
    p1 -= m;
    p2 -= m;
    if (p1 >= 7) {
      print(">");
    } else if (p2 >= 7) {
      print("<");
    } else {
      for (var j = 0; j < p1; j++) {
        x1 *= 10;
      }
      for (var j = 0; j < p2; j++) {
        x2 *= 10;
      }
      if (x1 > x2) {
        print(">");
      } else if (x1 < x2) {
        print("<");
      } else {
        print("=");
      }
    }
  }

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--) {
		let [x1, p1] = rna();
		let [x2, p2] = rna();

		while (x1 <= 1e6-1 && p1) { x1 *= 10; p1--; }
		while (x2 <= 1e6-1 && p2) { x2 *= 10; p2--; }
		let ans = x1 - x2;

		if (ans <  0) console.log('<');
		if (ans == 0) console.log('=');
		if (ans >  0) console.log('>');
	}
}

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--) {
		let [x1, p1] = rna();
		let [x2, p2] = rna();

		let ans;
		if (String(x1).length + p1 < String(x2).length + p2)
			ans = -1;
		else if (String(x1).length + p1 > String(x2).length + p2)
			ans = 1;
		else {
			while (x1 <= 1e6) x1 *= 10;
			while (x2 <= 1e6) x2 *= 10;
			ans = x1 - x2;
		}

		if (ans <  0) console.log('<');
		if (ans == 0) console.log('=');
		if (ans >  0) console.log('>');
	}
}

/**
 * https://codeforces.com/problemset/problem/1613/A
 */

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

    const input = [];
    return new Promise((resolve) => {
        readLine.on('close', () => resolve(input));
        readLine.on('line', (line) => input.push(line));
    });
}

/**
 *
 * @param {Array<number>} data
 * @param {number} testCount
 * @param {number} linesPerCase
 * @returns {Array<string>}
 */
function* splitTestCase(data, testCount, linesPerCase) {
    for (let i = 0, ii = 0; i < testCount; i++, ii = i * linesPerCase) {
        yield data.slice(ii, ii + linesPerCase);
    }
}

/**
 *
 * @param {Array<string>} arr
 * @returns {number}
 */
function len(arr) {
    return arr[0].length + Number.parseInt(arr[1]) || 0;
}

/**
 *
 * @param {number} x1
 * @param {number} x2
 * @returns {string | undefined}
 */
function compare(x1, x2) {
    console.log('>>>>', x1, x2);
    if (x1 > x2) { return '>'; }
    if (x1 < x2) { return '<'; }

    return;
}

/**
 *
 * @param {Array<string>} input1
 * @param {Array<string>} input2
 */
function run(input1, input2) {
    // Early escape
    if (input1 === input2) { return '='; }

    let result = compare(len(input1), len(input2));
    if (result) { return result; }

    // Inputs have the same length, normalize length of meaningful part and compare
    const normalizedLen = Math.max(input1[0].length, input2[0].length);
    result = compare(Number.parseInt(input1[0].padEnd(normalizedLen, 0)), Number.parseInt(input2[0].padEnd(normalizedLen, 0)));
    if (result) { return result; }

    return '=';
}

nodeJSReader().then(([
    testCount,
    ...data
]
) => {
    for (const testCase of splitTestCase(data, testCount, 2)) {
        console.log(run(testCase[0].split(' '), testCase[1].split(' ')));
    }
});

/**
 * https://codeforces.com/problemset/problem/1613/A
 */

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

    const input = [];
    return new Promise((resolve) => {
        readLine.on('close', () => resolve(input));
        readLine.on('line', (line) => input.push(line));
    });
}

/**
 *
 * @param {Array<number>} data
 * @param {number} testCount
 * @param {number} linesPerCase
 * @returns {Array<string>}
 */
function* splitTestCase(data, testCount, linesPerCase) {
    for (let i = 0, ii = 0; i < testCount; i++, ii = i * linesPerCase) {
        yield data.slice(ii, ii + linesPerCase);
    }
}

/**
 *
 * @param {Array<string>} arr
 * @returns {number}
 */
function len(arr) {
    return arr[0].length + Number.parseInt(arr[1]) || 0;
}

/**
 *
 * @param {number} x1
 * @param {number} x2
 * @returns {string | undefined}
 */
function compare(x1, x2) {
    console.log('>>>>', x1, x2);
    if (x1 > x2) { return '>'; }
    if (x1 < x2) { return '<'; }

    return;
}

/**
 *
 * @param {Array<string>} input1
 * @param {Array<string>} input2
 */
function run(input1, input2) {
    // Early escape
    if (input1 === input2) { return '='; }

    let result = compare(len(input1), len(input2));
    if (result) { return result; }

    // Inputs have the same length, normalize length of meaningful part and compare
    const normalizedLen = Math.max(input1[0].length, input2[0].length);
    result = compare(Number.parseInt(input1[0].padEnd(normalizedLen, 0)), Number.parseInt(input2[0].padEnd(normalizedLen, 0)));
    if (result) { return result; }

    return '=';
}

nodeJSReader().then(([
    testCount,
    ...data
]
) => {
    for (const testCase of splitTestCase(data, testCount, 2)) {
        console.log(testCase, run(testCase[0].split(' '), testCase[1].split(' ')));
    }
});

var pairsCount = parseInt(readline());

var results = [];

function compareNumbers(n1, n2) {
    if (n1 < n2) return '<';
    if (n1 > n2) return '>';
    return '=';
}

function addZeroesToNumber(str, zeroCount) {
    if (zeroCount === 0 || zeroCount === '0') {
        return parseInt(str);
    }
    var i = zeroCount;
    var res = str + '';
    while (i > 0) {
        res += '0';
        i--;
    }
    return parseInt(res);
}

function getReadLineArray() {
    return readline().toString().trim().split(" ");
}

function getNumber(arr1, arr2, p_diff) {
    return arr1[1] > arr2[1] ? addZeroesToNumber(arr1[0], p_diff) : parseInt(arr1[0]);
}

var i = 0;
while (i < pairsCount) {
    var arr1 = getReadLineArray();
    var arr2 = getReadLineArray();

    var digs1 = arr1[0] === '0' ? 0 : (arr1[0].length + parseInt(arr1[1]));
    var digs2 = arr2[0] === '0' ? 0 : (arr2[0].length + parseInt(arr2[1]));

    if (digs1 === digs2) {
        var p_diff = Math.abs(arr1[1] - arr2[1]);
        var n1 = addZeroesToNumber(arr1[0], arr1[1] > arr2[1] ? p_diff : 0);
        var n2 = addZeroesToNumber(arr2[0], arr2[1] > arr1[1] ? p_diff : 0);
        results.push(compareNumbers(n1, n2));
    } else results.push(compareNumbers(digs1, digs2));
    i++;
}

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

var pairsCount = parseInt(readline());

var results = [];

function compareNumbers(n1, n2) {
    if (n1 < n2) return '<';
    if (n1 > n2) return '>';
    return '=';
}

function addZeroesToNumber(str, zeroCount) {
    var i = zeroCount;
    var res = str + '';
    while (i > 0) {
        res += '0';
        i--;
    }
    return parseInt(res);
}

function getReadLineArray() {
    return readline().toString().trim().split(" ");
}

function getNumber(arr1, arr2, p_diff) {
    return arr1[1] > arr2[1] ? addZeroesToNumber(arr1[0], p_diff) : parseInt(arr1[0]);
}

var i = 0;
while (i < pairsCount) {
    var arr1 = getReadLineArray();
    var arr2 = getReadLineArray();

    var digs1 = arr1[0] === '0' ? 0 : (arr1[0].length + parseInt(arr1[1]));
    var digs2 = arr2[0] === '0' ? 0 : (arr2[0].length + parseInt(arr2[1]));

    if (digs1 === digs2) {
        var p_diff = Math.abs(arr1[1] - arr2[1]);
        var n1 = addZeroesToNumber(arr1[0], arr1[1] > arr2[1] ? p_diff : 0);
        var n2 = addZeroesToNumber(arr2[0], arr2[1] > arr1[1] ? p_diff : 0);
        results.push(compareNumbers(n1, n2));
    } else results.push(compareNumbers(digs1, digs2));
    i++;
}

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

var pairsCount = parseInt(readline());

var results = [];

function compareNumbers(n1, n2) {
    if (n1 < n2) return '<';
    if (n1 > n2) return '>';
    return '=';
}

function addZeroesToNumber(str, zeroCount) {
    var i = zeroCount;
    var res = str + '';
    while (i > 0) {
        res += '0';
        i--;
    }
    return parseInt(res);
}

function getReadLineArray() {
    return readline().toString().trim().split(" ");
}

function getNumber(arr1, arr2, p_diff) {
    return arr1[1] > arr2[1] ? addZeroesToNumber(arr1[0], p_diff) : parseInt(arr1[0]);
}

var i = 0;
while (i < pairsCount) {
    var arr1 = getReadLineArray();
    var arr2 = getReadLineArray();

    var digs1 = (arr1[0] === '0' ? 0 : arr1[0].length) + parseInt(arr1[1]);
    var digs2 = (arr2[0] === '0' ? 0 : arr2[0].length) + parseInt(arr2[1]);

    if (digs1 === digs2) {
        var p_diff = Math.abs(arr1[1] - arr2[1]);
        var n1 = addZeroesToNumber(arr1[0], arr1[1] > arr2[1] ? p_diff : 0);
        var n2 = addZeroesToNumber(arr2[0], arr2[1] > arr1[1] ? p_diff : 0);
        results.push(compareNumbers(n1, n2));
    } else results.push(compareNumbers(digs1, digs2));
    i++;
}

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

var pairsCount = parseInt(readline());

var results = [];

function compareNumbers(n1, n2) {
    if (n1 < n2) return '<';
    if (n1 > n2) return '>';
    return '=';
}

function addZeroesToNumber(str, zeroCount) {
    var i = zeroCount;
    var res = str + '';
    while (i > 0) {
        res += '0';
        i--;
    }
    return parseInt(res);
}

function getReadLineArray() {
    return readline().toString().trim().split(" ");
}

function getNumber(arr1, arr2, p_diff) {
    return arr1[1] > arr2[1] ? addZeroesToNumber(arr1[0], p_diff) : parseInt(arr1[0]);
}

var i = 0;
while (i < pairsCount) {
    var arr1 = getReadLineArray();
    var arr2 = getReadLineArray();

    var digs1 = arr1[0].length + parseInt(arr1[1]);
    var digs2 = arr2[0].length + parseInt(arr2[1]);

    if (digs1 === digs2) {
        var p_diff = Math.abs(arr1[1] - arr2[1]);
        var n1 = addZeroesToNumber(arr1[0], arr1[1] > arr2[1] ? p_diff : 0);
        var n2 = addZeroesToNumber(arr2[0], arr2[1] > arr1[1] ? p_diff : 0);
        results.push(compareNumbers(n1, n2));
    } else results.push(compareNumbers(digs1, digs2));
    i++;
}

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

var pairsCount = parseInt(readline());

var results = [];

function compareNumbers(n1, n2) {
    if (n1 < n2) return '<';
    if (n1 > n2) return '>';
    return '=';
}

function addZeroesToNumber(str, zeroCount) {
    var i = zeroCount;
    var res = str;
    while (i>0) {
        res += '0';
        i--;
    }
    return parseInt(res);
}

function getReadLineArray() {
    return readline().toString().trim().split(" ");
}

function getNumber(arr1, arr2, p_diff) {
    return arr1[1] > arr2[1] ? addZeroesToNumber(arr1[0], p_diff) : parseInt(arr1[0]);
}

var i = 0;
while (i < pairsCount) {
    var arr1 = getReadLineArray();
    var arr2 = getReadLineArray();

    var p_diff = Math.abs(arr1[1] - arr2[1]);

    var n1 = getNumber(arr1, arr2, p_diff);
    var n2 = getNumber(arr2, arr1, p_diff);
    results.push(compareNumbers(n1, n2))
    i++;
}

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

var pairsCount = parseInt(readline());

var results = [];

function compareNumbers(n1, n2) {
    if (n1 < n2) return '<';
    if (n1 > n2) return '>';
    return '=';
}

function addZeroesToNumber(str, zeroCount) {
    var i = zeroCount;
    var res = str;
    while (i>0) {
        res += '0';
        i--;
    }
    return parseInt(res);
}

function getReadLineArray() {
    return readline().toString().trim().split(" ");
}

function getNumber(arr1, arr2, p_diff) {
    return arr1[1] > arr2[1] ? addZeroesToNumber(arr1[0], p_diff) : parseInt(arr1[0]);
}

var i = 0;
while (i < pairsCount) {
    var arr1 = getReadLineArray();
    var arr2 = getReadLineArray();

    var p_diff = Math.abs(arr1[1] - arr2[1]);

    var n1 = getNumber(arr1, arr2, p_diff);
    var n2 = getNumber(arr2, arr1, p_diff);
    print(n1, n2);
    results.push(compareNumbers(n1, n2))
    i++;
}

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

var pairsCount = parseInt(readline());

var results = [];

function compareNumbers(n1, n2) {
    if (n1 < n2) return '<';
    if (n1 > n2) return '>';
    return '=';
}

function addZeroesToNumber(str, zeroCount) {
    var i = zeroCount;
    var res = str;
    while (i>0) {
        res += '0';
        i--;
    }
    return parseInt(res);
}

function getReadLineArray() {
    return readline().toString().split(" ");
}

var i = 0;
while (i < pairsCount) {
    var arr1 = getReadLineArray();
    var arr2 = getReadLineArray();

    var p2 = Math.abs(arr1[1] - arr2[1]);

    var n1 = addZeroesToNumber(arr1[0], arr1[1] > arr2[1] ? p2 : 0);
    var n2 = addZeroesToNumber(arr2[0], arr2[1] > arr1[1] ? p2 : 0);
    results.push(compareNumbers(n1, n2))
    i++;
}

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

var t = +readline();

while(t--) {
    var description1 = readline().split(' ').map(Number);
    var description2 = readline().split(' ').map(Number);

    var firstNumber = description1[0] * (Math.pow(10, description1[1]));
    var secondNumber = description2[0] * (Math.pow(10, description2[1]));

    print(firstNumber === secondNumber ? '=' : firstNumber > secondNumber ? '>' : '<');
}


Alice and Bob have received three big piles of candies as a gift. Now they want to divide these candies as fair as possible. To do this, Alice takes one pile of candies, then Bob takes one of the other two piles. The last pile is split between Alice and Bob as they want: for example, it is possible that Alice takes the whole pile, and Bob gets nothing from it.After taking the candies from the piles, if Alice has more candies than Bob, she discards some candies so that the number of candies she has is equal to the number of candies Bob has. Of course, Bob does the same if he has more candies.Alice and Bob want to have as many candies as possible, and they plan the process of dividing candies accordingly. Please calculate the maximum number of candies Alice can have after this division process (of course, Bob will have the same number of candies).You have to answer $$$q$$$ independent queries.Let's see the following example: $$$[1, 3, 4]$$$. Then Alice can choose the third pile, Bob can take the second pile, and then the only candy from the first pile goes to Bob — then Alice has $$$4$$$ candies, and Bob has $$$4$$$ candies.Another example is $$$[1, 10, 100]$$$. Then Alice can choose the second pile, Bob can choose the first pile, and candies from the third pile can be divided in such a way that Bob takes $$$54$$$ candies, and Alice takes $$$46$$$ candies. Now Bob has $$$55$$$ candies, and Alice has $$$56$$$ candies, so she has to discard one candy — and after that, she has $$$55$$$ candies too.

The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of queries. Then $$$q$$$ queries follow. The only line of the query contains three integers $$$a, b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^{16}$$$) — the number of candies in the first, second and third piles correspondingly.

Print $$$q$$$ lines. The $$$i$$$-th line should contain the answer for the $$$i$$$-th query — the maximum number of candies Alice can have after the division, if both Alice and Bob act optimally (of course, Bob will have the same number of candies).

var firstLine = +readline();
var i = 0;

while(i < firstLine) {
	var arr = readline().split(' ');
	var arrRes = arr.reduce((a,b) => add(a, b), "0");
    arrRes = divide(arrRes, 2).split('.')[0];
	print(arrRes[0] == "0" ? arrRes.substring(1) : arrRes);

	i++;
}

function add(str1, str2) {
    var sum = "";

    var str1Length = str1.length;
    var str2Length = str2.length;

    if(str2Length > str1Length ){
        var temp = str2;
        str2 = str1;
        str1 = temp;
    }

    var carry = 0;
    var a;
    var b;
    var temp;
    var digitSum;
    for (var i = 0; i < str1.length; i++) {
        a = parseInt(str1.charAt(str1.length - 1 - i));
        b = parseInt(str2.charAt(str2.length - 1 - i));
        b = (b) ? b : 0;
        temp = (carry + a + b).toString();
        digitSum = temp.charAt(temp.length - 1);
        carry = parseInt(temp.substr(0, temp.length - 1));
        carry = (carry) ? carry : 0;

        sum = (i === str1.length - 1) ? temp + sum : digitSum + sum;

    }

    return sum;     // return sum

}

function divide(n,d){
    var num = n + "",
        numLength = num.length,
        remainder = 0,
        answer = '',
        i = 0;

    while( i < numLength + 3){
        var digit = i < numLength ? parseInt(num[i]) : 0;

        if (i == numLength){
            answer = answer + ".";
        }

        answer = answer + Math.floor((digit + (remainder * 10))/d);
        remainder = (digit + (remainder * 10))%d;
        i++;
    }
    return answer;
}

function padStart(str, count, symbol) {
  for(var i = str.length; i < count; i++) {
    str = '0' + str;
  }

  return str;
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ');

  if(Math.max(...arr.map(item => item.length)) > 10) {
    var res = parseInt(arr.map(item => +item.slice(0, -7) / 2).reduce((prev, curr) => prev + curr));
    var lres = parseInt(arr.map(item => +item.slice(-13) / 2).reduce((prev, curr) => prev + curr));
    print(res.toString().slice(0, -3) + padStart(lres.toString().slice(-10), 10, '0'));
  } else {
    var res = parseInt(arr.map(item => +item).reduce((prev, curr) => prev + curr) / 2);
    print(res);
  }
}

var firstLine = +readline();
var i = 0;

while(i < firstLine) {
	var arr = readline().split(' ');
	var arrRes = arr.reduce((a,b) => add(a, b), "0");

    arrRes = divide(arrRes, 2)
	print(arrRes.split('.')[0]);

	i++;
}

function add(str1, str2) {
    var sum = "";

    var str1Length = str1.length;
    var str2Length = str2.length;

    if(str2Length > str1Length ){
        var temp = str2;
        str2 = str1;
        str1 = temp;
    }

    var carry = 0;
    var a;
    var b;
    var temp;
    var digitSum;
    for (var i = 0; i < str1.length; i++) {
        a = parseInt(str1.charAt(str1.length - 1 - i));
        b = parseInt(str2.charAt(str2.length - 1 - i));
        b = (b) ? b : 0;
        temp = (carry + a + b).toString();
        digitSum = temp.charAt(temp.length - 1);
        carry = parseInt(temp.substr(0, temp.length - 1));
        carry = (carry) ? carry : 0;

        sum = (i === str1.length - 1) ? temp + sum : digitSum + sum;

    }

    return sum;     // return sum

}

function divide(n,d){
    var num = n + "",
        numLength = num.length,
        remainder = 0,
        answer = '',
        i = 0;

    while( i < numLength + 3){
        var digit = i < numLength ? parseInt(num[i]) : 0;

        if (i == numLength){
            answer = answer + ".";
        }

        answer = answer + Math.floor((digit + (remainder * 10))/d);
        remainder = (digit + (remainder * 10))%d;
        i++;
    }
    return answer;
}

var firstLine = +readline();
var i = 0;

while(i < firstLine) {
	var arr = readline().split(' ');
	var arrSum = arr.reduce((a,b) => add(a, b), "0");

	print(Math.floor(divide(arrSum, 2)));

	i++;
}

function add(str1, str2) {
    var sum = "";
    var str1Length = str1.length;
    var str2Length = str2.length;

    if(str2Length > str1Length ){
        var temp2 = str2;
        str2 = str1;
        str1 = temp2;
    }

    var carry = 0;  // number that is carried to next decimal place, initially zero.
    var a;
    var b;
    var temp;
    var digitSum;
    for (var i = 0; i < str1.length; i++) {
        a = parseInt(str1.charAt(str1.length - 1 - i));
        b = parseInt(str2.charAt(str2.length - 1 - i));
        b = (b) ? b : 0;
        temp = (carry + a + b).toString();
        digitSum = temp.charAt(temp.length - 1);
        carry = parseInt(temp.substr(0, temp.length - 1));
        carry = (carry) ? carry : 0;

        sum = (i === str1.length - 1) ? temp + sum : digitSum + sum;
    }

    return sum;     // return sum
}

function divide(n,d){
    var num = n + "",
        numLength = num.length,
        remainder = 0,
        answer = '',
        i = 0;

    while( i < numLength + 3){
        var digit = i < numLength ? parseInt(num[i]) : 0;

        if (i == numLength){
            answer = answer + ".";
        }

        answer = answer + Math.floor((digit + (remainder * 10))/d);
        remainder = (digit + (remainder * 10))%d;
        i++;
    }
    return parseFloat(answer);
}

function padStart(str, count, symbol) {
  for(var i = str.length; i < count; i++) {
    str = '0' + str;
  }

  return str;
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ');

  if(Math.max(...arr.map(item => item.length)) > 10) {
    var res = parseInt(arr.map(item => +item.slice(0, -8)).reduce((prev, curr) => prev + curr) / 2);
    var lres = parseInt(arr.map(item => +item.slice(-10)).reduce((prev, curr) => prev + curr) / 2);
    print(res.toString() + padStart(lres.toString().slice(-8), 8, '0'));
  } else {
    var res = parseInt(arr.map(item => +item).reduce((prev, curr) => prev + curr) / 2);
    print(res);
  }
}

function padStart(str, count, symbol) {
  for(var i = str.length; i < count; i++) {
    str = '0' + str;
  }

  return str;
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ');
  var res = parseInt(arr.map(item => +item).reduce((prev, curr) => prev + curr) / 2);

  if(res > Number.MAX_SAFE_INTEGER) {
    var lres = parseInt(arr.map(item => +item.slice(-10)).reduce((prev, curr) => prev + curr) / 2);
    print(res.toString().slice(0, -10) + padStart(lres.toString().slice(-10), 10, '0'));
  } else {
    print(res);
  }
}

function padStart(str, count, symbol) {
  for(var i = str.length; i < count; i++) {
    str = '0' + str;
  }

  return str;
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ');

  if(Math.max(...arr.map(item => item.length)) > 10) {
    var res = parseInt(arr.map(item => +item.slice(0, -8) / 2).reduce((prev, curr) => prev + curr));
    var lres = parseInt(arr.map(item => +item.slice(-12) / 2).reduce((prev, curr) => prev + curr));
    print(res.toString().slice(0, -2) + padStart(lres.toString().slice(-10), 10, '0'));
  } else {
    var res = parseInt(arr.map(item => +item).reduce((prev, curr) => prev + curr) / 2);
    print(res);
  }
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var val = readline().split(' ').reduce((curr, prev) => curr + (+prev), 0);
  print(Math.floor(val / 2));
}

function padStart(str, count, symbol) {
  for(var i = str.length; i < count; i++) {
    str = '0' + str;
  }

  return str;
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ');
  var res = parseInt(arr.map(item => +item).reduce((prev, curr) => prev + curr) / 2);

  if(res > 10000000000) {
    var lres = parseInt(arr.map(item => +item.slice(-10)).reduce((prev, curr) => prev + curr) / 2);
    print(res.toString().slice(0, -9) + padStart(lres.toString().slice(-9), 9, '0'));
  } else {
    print(res);
  }
}

function padStart(str, count, symbol) {
  for(var i = str.length; i < count; i++) {
    str = '0' + str;
  }

  return str;
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ');
  var res = parseInt(arr.map(item => +item.slice(0, -9)).reduce((prev, curr) => prev + curr) / 2);

  if(Math.max(...arr.map(item => item.length)) > 10) {
    var lres = parseInt(arr.map(item => +item.slice(-10)).reduce((prev, curr) => prev + curr) / 2);
    print(res.toString().slice(0, -1) + padStart(lres.toString().slice(-9), 9, '0'));
  } else {
    print(res);
  }
}

function padStart(str, count, symbol) {
  for(var i = str.length; i < count; i++) {
    str = '0' + str;
  }

  return str;
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ');
  var res = parseInt(arr.map(item => +item).reduce((prev, curr) => prev + curr) / 2);

  if(res > Number.MAX_SAFE_INTEGER) {
    var lres = parseInt(arr.map(item => +item.slice(-10)).reduce((prev, curr) => prev + curr) / 2);
    print(res.toString().slice(0, -9) + padStart(lres.toString().slice(-9), 9, '0'));
  } else {
    print(res);
  }
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ');
  var res = parseInt(arr.map(item => +item).reduce((prev, curr) => prev + curr) / 2);

  if(res > Number.MAX_SAFE_INTEGER) {
    lres = parseInt(arr.map(item => +item.slice(-10)).reduce((prev, curr) => prev + curr) / 2);
    print(res.toString().slice(0, -10) + lres.toString().slice(-10));
  } else {
    print(res);
  }
}

function padStart(str, count, symbol) {
  for(var i = str.length; i < count; i++) {
    str = '0' + str;
  }

  return str;
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ');

  if(Math.max(...arr.map(item => item.length)) > 10) {
    var res = parseInt(arr.map(item => +item.slice(0, -9)).reduce((prev, curr) => prev + curr) / 2);
    var lres = parseInt(arr.map(item => +item.slice(-10)).reduce((prev, curr) => prev + curr) / 2);
    print(res.toString() + padStart(lres.toString().slice(-9), 9, '0'));
  } else {
    var res = parseInt(arr.map(item => +item).reduce((prev, curr) => prev + curr) / 2);
    print(res);
  }
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ').map(item => +item).sort((a, b) => a - b);
  var sum = arr[1] + (arr[2] - arr[1] + arr[0]) / 2;

  print(Math.floor(sum));
}

function padStart(str, count, symbol) {
  for(var i = str.length; i < count; i++) {
    str = '0' + str;
  }

  return str;
}

var n = +readline();

for(var i = 0; i < n; i++) {
  var arr = readline().split(' ');
  var res = parseInt(arr.map(item => +item).reduce((prev, curr) => prev + curr) / 2);

  if(res > 1000000000) {
    var lres = parseInt(arr.map(item => +item.slice(-10)).reduce((prev, curr) => prev + curr) / 2);
    print(res.toString().slice(0, -9) + padStart(lres.toString().slice(-9), 10, '0'));
  } else {
    print(res);
  }
}


Shubham has a binary string $$$s$$$. A binary string is a string containing only characters "0" and "1".He can perform the following operation on the string any amount of times:   Select an index of the string, and flip the character at that index. This means, if the character was "0", it becomes "1", and vice versa. A string is called good if it does not contain "010" or "101" as a subsequence  — for instance, "1001" contains "101" as a subsequence, hence it is not a good string, while "1000" doesn't contain neither "010" nor "101" as subsequences, so it is a good string.What is the minimum number of operations he will have to perform, so that the string becomes good? It can be shown that with these operations we can make any string good.A string $$$a$$$ is a subsequence of a string $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero or all) characters.

The first line of the input contains a single integer $$$t$$$ $$$(1\le t \le 100)$$$ — the number of test cases. Each of the next $$$t$$$ lines contains a binary string $$$s$$$ $$$(1 \le |s| \le 1000)$$$.

For every string, output the minimum number of operations required to make it good.

NoteIn test cases $$$1$$$, $$$2$$$, $$$5$$$, $$$6$$$ no operations are required since they are already good strings.For the $$$3$$$rd test case: "001" can be achieved by flipping the first character  — and is one of the possible ways to get a good string.For the $$$4$$$th test case: "000" can be achieved by flipping the second character  — and is one of the possible ways to get a good string.For the $$$7$$$th test case: "000000" can be achieved by flipping the third and fourth characters  — and is one of the possible ways to get a good string.

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

    B();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let s = readline().split('');
        let leftOne = new Array(s.length);
        let rightOne = new Array(s.length);
        let leftZero = new Array(s.length);
        let rightZero = new Array(s.length);
        leftOne.fill(0);
        rightOne.fill(0);
        leftZero.fill(0);
        rightZero.fill(0);
        for(let i = 0; i < s.length; i++){
            if(i === 0){
                leftOne[i] = s[i] === '1' ? 1 : 0;
                leftZero[i] = s[i] === '0' ? 1 : 0;
            }else{
                leftOne[i] = s[i] === '1' ? leftOne[i-1]+1 : leftOne[i-1];
                leftZero[i] = s[i] === '0' ? leftZero[i-1]+1 : leftZero[i-1];
            }
        }

        for(let i = s.length-1; i >= 0; i--){
            if(i === s.length-1){
                rightOne[i] = s[i] === '1' ? 1 : 0;
                rightZero[i] = s[i] === '0' ? 1 : 0;
            }else{
                rightOne[i] = s[i] === '1' ? rightOne[i+1]+1 : rightOne[i+1];
                rightZero[i] = s[i] === '0' ? rightZero[i+1]+1 : rightZero[i+1];
            }
        }

        let min = 99999999999;
        for(let i = 0; i < s.length; i++){
            min = Math.min(min, leftZero[i] + rightOne[i], leftOne[i] + rightZero[i]);
        }

        console.log(min-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();
    });

    B();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let s = readline().split('');
        let leftOne = new Array(s.length);
        let rightOne = new Array(s.length);
        let leftZero = new Array(s.length);
        let rightZero = new Array(s.length);
        leftOne.fill(0);
        rightOne.fill(0);
        leftZero.fill(0);
        rightZero.fill(0);
        for(let i = 0; i < s.length; i++){
            if(i === 0){
                leftOne[i] = s[i] === '1' ? 1 : 0;
                leftZero[i] = s[i] === '0' ? 1 : 0;
            }else{
                leftOne[i] = s[i] === '1' ? leftOne[i-1]+1 : leftOne[i-1];
                leftZero[i] = s[i] === '0' ? leftZero[i-1]+1 : leftZero[i-1];
            }
        }

        for(let i = s.length-1; i >= 0; i--){
            if(i === s.length-1){
                rightOne[i] = s[i] === '1' ? 1 : 0;
                rightZero[i] = s[i] === '0' ? 1 : 0;
            }else{
                rightOne[i] = s[i] === '1' ? rightOne[i+1]+1 : rightOne[i+1];
                rightZero[i] = s[i] === '0' ? rightZero[i+1]+1 : rightZero[i+1];
            }
        }

        let min = 99999999999;
        for(let i = 0; i < s.length; i++){
            min = Math.min(leftZero[i] + rightOne[i], leftOne[i] + rightZero[i]);
        }

        console.log(min-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();
    });

    B();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let s = readline().split('');
        let leftOne = new Array(s.length);
        let rightOne = new Array(s.length);
        let leftZero = new Array(s.length);
        let rightZero = new Array(s.length);
        leftOne.fill(0);
        rightOne.fill(0);
        leftZero.fill(0);
        rightZero.fill(0);
        for(let i = 0; i < s.length; i++){
            if(i === 0){
                leftOne[i] = s[i] === '1' ? 1 : 0;
                leftZero[i] = s[i] === '0' ? 1 : 0;
            }else{
                leftOne[i] = s[i] === '1' ? leftOne[i-1]+1 : leftOne[i-1];
                leftZero[i] = s[i] === '0' ? leftZero[i-1]+1 : leftZero[i-1];
            }
        }

        for(let i = s.length-1; i >= 0; i--){
            if(i === s.length-1){
                rightOne[i] = s[i] === '1' ? 1 : 0;
                rightZero[i] = s[i] === '0' ? 1 : 0;
            }else{
                rightOne[i] = s[i] === '1' ? rightOne[i+1]+1 : rightOne[i+1];
                rightZero[i] = s[i] === '0' ? rightZero[i+1]+1 : rightZero[i+1];
            }
        }

        let min = 99999999999;
        for(let i = 0; i < s.length; i++){
            if(rightOne[i] === 0){
                min = Math.min(min, leftZero[i]);
            }

            if(rightZero[i] === 0){
                min = Math.min(min, leftOne[i]);
            }

            if(leftOne[i] === 0){
                min = Math.min(min, rightZero[i]);
            }

            if(leftZero[i] === 0){
                min = Math.min(min, rightOne[i]);
            }
        }

        console.log(min-1);
    }
}