You are given a huge decimal number consisting of $$$n$$$ digits. It is guaranteed that this number has no leading zeros. Each digit of this number is either 0 or 1.You may perform several (possibly zero) operations with this number. During each operation you are allowed to change any digit of your number; you may change 0 to 1 or 1 to 0. It is possible that after some operation you can obtain a number with leading zeroes, but it does not matter for this problem.You are also given two integers $$$0 \le y < x < n$$$. Your task is to calculate the minimum number of operations you should perform to obtain the number that has remainder $$$10^y$$$ modulo $$$10^x$$$. In other words, the obtained number should have remainder $$$10^y$$$ when divided by $$$10^x$$$.

The first line of the input contains three integers $$$n, x, y$$$ ($$$0 \le y < x < n \le 2 \cdot 10^5$$$) — the length of the number and the integers $$$x$$$ and $$$y$$$, respectively. The second line of the input contains one decimal number consisting of $$$n$$$ digits, each digit of this number is either 0 or 1. It is guaranteed that the first digit of the number is 1.

Print one integer — the minimum number of operations you should perform to obtain the number having remainder $$$10^y$$$ modulo $$$10^x$$$. In other words, the obtained number should have remainder $$$10^y$$$ when divided by $$$10^x$$$.

NoteIn the first example the number will be $$$11010100100$$$ after performing one operation. It has remainder $$$100$$$ modulo $$$100000$$$.In the second example the number will be $$$11010100010$$$ after performing three operations. It has remainder $$$10$$$ modulo $$$100000$$$.

try {require("codeforces")} catch(e){};

let fs =  require('fs');
let input = (fs.readFileSync2 || fs.readFileSync)(0, 'ascii').split('\n').map(s => s.trim());

let [n, x, y] = input[0].split(" ").map(Number);
let ch = input[1];

ch = ch.substr(-x).split("");
ch.reverse();
console.log(ch.filter(function(ch, index) {return index === y && ch === "0" || index !== y && ch === "1"}).length);

'use strict';

function main() {
  let n = 0, x = 0, y = 0, s = '';
  let i = 0, toBeChanged = 0;
  n = parseInt(next()), x = parseInt(next()), y = parseInt(next()), s = next();
  for(i = n-x; i < n; i++) {
    if(i != n-y-1) {
      toBeChanged += s[i] === '1';
    } else {
      toBeChanged += s[i] === '0';
    }
  }
  println(toBeChanged);
}

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

let input = "";
process.stdin.on('data', (chunk) => input += chunk);

// next: reads next value from input.
let inputCursor = 0;
let next = () => {
  return inputCursor < input.length ? input[inputCursor++] : '';
};

//print: print one or more space seperated values.
let print = (...data) => {
  for(let i = 0; i < data.length; i++) {
    process.stdout.write('' + data[i] + (i < data.length - 1 ? ' ' : ''));
  }
};

//println: print one or more space seperated values then a line feed.
let println = (...data) => {
  print(...data);
  print('\n');
};

//after the the input is read.
process.stdin.on('end', () => {
    input = input.trim().split(/[\s]+/);
    main();
});

'use strict'

function main() {
  let n, x, y, s;
  n = parseInt(next()), x = parseInt(next()), y = parseInt(next()), s = next();
  let toBeChanged = 0;
  for(let i = n-x; i < n; i++) {
    if(i != n-y-1) {
      toBeChanged += s[i] == '1';
    } else {
      toBeChanged += s[i] == '0';
    }
  }
  println(toBeChanged);
}

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

let input = "";
process.stdin.on('data', (chunk) => input += chunk);

// next: reads next value from input.
let inputCursor = 0;
let next = () => {
  return inputCursor < input.length ? input[inputCursor++] : '';
};

//print: print one or more space seperated values.
let print = (...data) => {
  for(let i = 0; i < data.length; i++) {
    process.stdout.write('' + data[i] + (i < data.length - 1 ? ' ' : ''));
  }
};

//println: print one or more space seperated values then a line feed.
let println = (...data) => {
  print(...data);
  print('\n');
};

//after the the input is read.
process.stdin.on('end', () => {
    input = input.trim().split(/[\s]+/);
    main();
});

'use strict'

function main() {
  let n = 0, x = 0, y = 0, s = '';
  let i = 0, toBeChanged = 0;
  n = parseInt(next()), x = parseInt(next()), y = parseInt(next()), s = next();
  for(i = n-x; i < n; i++) {
    if(i != n-y-1) {
      toBeChanged += s[i] === '1';
    } else {
      toBeChanged += s[i] === '0';
    }
  }
  println(toBeChanged);
}

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

let input = "";
process.stdin.on('data', (chunk) => input += chunk);

// next: reads next value from input.
let inputCursor = 0;
let next = () => {
  return inputCursor < input.length ? input[inputCursor++] : '';
};

//print: print one or more space seperated values.
let print = (...data) => {
  for(let i = 0; i < data.length; i++) {
    process.stdout.write('' + data[i] + (i < data.length - 1 ? ' ' : ''));
  }
};

//println: print one or more space seperated values then a line feed.
let println = (...data) => {
  print(...data);
  print('\n');
};

//after the the input is read.
process.stdin.on('end', () => {
    input = input.trim().split(/[\s]+/);
    main();
});

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

    var line = read.arrNumber(' ');
    var n = line[0];
    var x = line[1];
    var y = line[2];

    var s = read.arr('');

    var res = 0;
    for(var i = n - 1; i > n - x - 1; i-- ) {
        if(i == n - y - 1) {
            if(s[i] === '0')
                res++
        }
        else {
            if(s[i] === '1') {
                res++;
            }
        }

    }
    print(res);
}());

var input = readline().split(' ').map(Number);
var n, x, y;
n = input.shift();
x = input.shift();
y = input.shift();
var str = readline();
var res = 0;
for(var i = n - 1; i >= n - x; i--){
    if(str[i] == '1' && Math.abs(n - i - 1) != y){
        res++;
    } else if(str[i] == '0' && Math.abs(n - 1 - i) == y)
        res++;
}
print(res);

var input = readline().split(" ").map(Number);
var n = input.shift();
var x = input.shift();
var y = input.shift();
var ch = readline();
ch = ch.substr(-x).split("");
ch.reverse();
write(ch.filter(function(ch, index) {return index === y && ch === "0" || index !== y && ch === "1"}).length);

'use strict'

function main() {
  let n, x, y, s;
  n = parseInt(next()), x = parseInt(next()), y = parseInt(next()), s = next();
  let toBeChanged = 0;
  for(let i = n-x; i < n; i++) {
    if(i != 11-y-1) {
      toBeChanged += s[i] == '1';
    } else {
      toBeChanged += s[i] == '0';
    }
  }
  println(toBeChanged);
}

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

let input = "";
process.stdin.on('data', (chunk) => input += chunk);

// next: reads next value from input.
let inputCursor = 0;
let next = () => {
  return inputCursor < input.length ? input[inputCursor++] : '';
};

//print: print one or more space seperated values.
let print = (...data) => {
  for(let i = 0; i < data.length; i++) {
    process.stdout.write('' + data[i] + (i < data.length - 1 ? ' ' : ''));
  }
};

//println: print one or more space seperated values then a line feed.
let println = (...data) => {
  print(...data);
  print('\n');
};

//after the the input is read.
process.stdin.on('end', () => {
    input = input.trim().split(/[\s]+/);
    main();
});


One day Ms Swan bought an orange in a shop. The orange consisted of n·k segments, numbered with integers from 1 to n·k. There were k children waiting for Ms Swan at home. The children have recently learned about the orange and they decided to divide it between them. For that each child took a piece of paper and wrote the number of the segment that he would like to get: the i-th (1 ≤ i ≤ k) child wrote the number ai (1 ≤ ai ≤ n·k). All numbers ai accidentally turned out to be different.Now the children wonder, how to divide the orange so as to meet these conditions:  each child gets exactly n orange segments;  the i-th child gets the segment with number ai for sure;  no segment goes to two children simultaneously. Help the children, divide the orange and fulfill the requirements, described above.

The first line contains two integers n, k (1 ≤ n, k ≤ 30). The second line contains k space-separated integers a1, a2, ..., ak (1 ≤ ai ≤ n·k), where ai is the number of the orange segment that the i-th child would like to get. It is guaranteed that all numbers ai are distinct.

Print exactly n·k distinct integers. The first n integers represent the indexes of the segments the first child will get, the second n integers represent the indexes of the segments the second child will get, and so on. Separate the printed numbers with whitespaces. You can print a child's segment indexes in any order. It is guaranteed that the answer always exists. If there are multiple correct answers, print any of them.

print(function(n, k) {

	var l = n * k;
	var a = new Int32Array(l + 1);

	readline().split(' ').forEach(function(v, i) {
		a[v] = i + 1;
	});

	var ret = [];
	for (var i = 0; i < k; i++)
		ret.push([]);

	for (var i = 1, c = 0, j = 0; i <= l; i++) {
		if (c === n - 1) {
			c = 0;
			j++;
		}
		if (a[i] === 0) {
			c++;
			ret[j].push(i);
		} else {
			ret[a[i] - 1].push(i);
		}
	}

	return ret.map(function(v) {
		return v.join(' ');
	}).join('\n');

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

;(function () {

	print(function(n, k) {
		var t = [], a = readline().split(' ').map(Number);
		a.forEach(function (e) { t.push([e]); });

		for (var i = 1, _i = n * k + 1, l = 0; i < _i; i++) {
			if (a.indexOf(i) !== -1) continue;

			if (t[l].length === n) l++;
			t[l].push(i);
		}

		return t.map(function (e) { return e.join(' '); }).join('\n');
	}.apply(null, readline().split(' ').map(Number)));

}).call(this);

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

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

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

function main() {
	var data = tokenizeIntegers(readline()),
		n = data[0], k = data[1],
		childPieces = tokenizeIntegers(readline()),
		piece2child = {}, child2piece = {};
	for (var i = 0; i < childPieces.length; ++i) {
		var piece = childPieces[i], child = i+1;
		piece2child[piece] = child;
		child2piece[child] = piece;
	}
	var piece = 0;
	for (var child = 1; child <= k; ++child) {
		var result = [child2piece[child]];
		for (var j = 1; j < n; ++j) {
			++piece;
			while (piece2child[piece] !== undefined) {
				++piece;
			}
			result.push(piece);
		}
		print(result.join(' '));
	}
}

main();

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

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

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

function main() {
	var data = tokenizeIntegers(readline()),
		n = data[0], k = data[1],
		childPieces = tokenizeIntegers(readline()),
		used = {}, rows = [];
	for (var i = 0; i < childPieces.length; ++i) {
		used[childPieces[i]] = true;
		rows.push([childPieces[i]]);
	}
	var child = 0, limit = n*k;
	for (var piece = 1; piece <= limit; ++piece) {
		if (!used[piece]) {
			rows[child].push(piece);
			if (rows[child].length == n) {
				++child;
			}
		}
	}
	var lines = [];
	for (var child = 0; child < k; ++child) {
		lines.push(rows[child].join(' '));
	}
	print(lines.join('\n'));
}

main();

print(function(n, k) {

	var a = ('0 ' + readline()).split(' ').map(Number);

	for (var i = n - 1; i >= 1; i--)
		if (a[i] !== a[i + 1])
			return i >= k ? -1 : i;

	return 0;

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

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

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

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

function main() {
	var data = tokenizeIntegers(readline()),
		n = data[0], k = data[1],
		childPieces = tokenizeIntegers(readline()),
		used = {}, rows = [];
	for (var i = 0; i < childPieces.length; ++i) {
		used[childPieces[i]] = true;
		rows.push([childPieces[i]]);
	}
	var child = 0, limit = n*k, lines = [];
	for (var piece = 1; piece <= limit; ++piece) {
		if (!used[piece]) {
			rows[child].push(piece);
			if (rows[child].length == n) {
				lines.push(rows[child].join(' '));
				++child;
			}
		}
	}
	print(lines.join('\n'));
}

main();


Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot.He wants the fence to be a regular polygon. The robot builds the fence along a single path, but it can only make fence corners at a single angle a.Will the robot be able to build the fence Emuskald wants? In other words, is there a regular polygon which angles are equal to a?

The first line of input contains an integer t (0 < t < 180) — the number of tests. Each of the following t lines contains a single integer a (0 < a < 180) — the angle the robot can make corners at measured in degrees.

For each test, output on a single line "YES" (without quotes), if the robot can build a fence Emuskald wants, and "NO" (without quotes), if it is impossible.

NoteIn the first test case, it is impossible to build the fence, since there is no regular polygon with angle .In the second test case, the fence is a regular triangle, and in the last test case — a square.

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

//main
function main() {
    var totalTests = parseInt(readline());
    for (var i=0 ; i < totalTests ; i++) {
        console.log(360 % (180 - parseInt(readline())) ? "NO" : "YES");
    }

}

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

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [n] = input[0].split(' ').map(x => parseInt(x));

  input.forEach((x, i) => {
    if (i === 0) return;

    if (360 % (180 - x) === 0)
      console.log('YES');
    else
      console.log('NO');
  });
});

// https://codeforces.com/problemset/problem/270/A
// Big O:
// Time complexity: O(n)
// Space complexity: O(n)

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

let tests;
let angles = [];
let counter = 0;
rl.on('line', (input) => {
    if (!tests) {
        tests = parseInt(input);
        return;
    }

    counter++;
    if (counter <= tests) {
        angles.push(parseInt(input));
    }

    if (counter === tests) {
        solve(angles);
        rl.close();
    }

});

function solve(angles) {
    for (angle of angles) {
        const output = isRegularPolygon(angle) ? "YES" : "NO";
        console.log(output);
    }
}

// Problem
// For a regular convex n-gon, each interior angle has a measure of: 180(n-2)/n degrees
function isRegularPolygon(angle) {
    const modulus = 360 % (180 - angle);
    return modulus === 0;
}

// https://codeforces.com/problemset/problem/270/A
// Big O:
// Time complexity:
// Space complexity:

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

let tests;
let angles = [];
let counter = 0;
rl.on('line', (input) => {
    if (!tests) {
        tests = parseInt(input);
        return;
    }

    counter++;
    if (counter <= tests) {
        angles.push(parseInt(input));
    }

    if (counter === tests) {
        readAngles(angles);
        rl.close();
    }

});

function readAngles(angles) {
    for (angle of angles) {
        const isRegularPolygon = canBuildRegularPolygon(angle)
        console.log(isRegularPolygon ? "YES" : "NO");
    }
}

// Problem
// For a regular convex n-gon, each interior angle has a measure of: 180(n-2)/n degrees
function canBuildRegularPolygon(angle) {
    const modulus = 360 % (180 - angle);
    return modulus === 0;
}

function main(stdin) {
  const lines = stdin.split("\n");
  lines.slice(1).forEach(v => {
    console.log(360 % (180 - parseInt(v)) === 0 ? "YES" : "NO");
  });
}

main(
  require("fs")
    .readFileSync(0, "utf-8")
    .trim()
);

var t = parseInt( readline(), 10 );
var answers = [];
while ( t-- ) {
  var a = parseInt( readline(), 10 );
  answers.push( 360%(180 - a) === 0 ? "YES" : "NO" );
}
print( answers.join( "\n" ) );

var limit= parseInt(readline());
var angle;
for (var i = 0; i < limit; i++) {
  angle = parseInt(readline());
  if (360 % (180-angle) === 0) print('YES');
  else print('NO');
}

var t=+readline();
while(t--){
	print(0 === 360%( 180-readline() ) ? 'YES' : 'NO');
}

var n = parseInt(readline());
var inp, k;

for(var i=0; i<n; i++)
{
  inp = parseInt(readline());
  k = 360/(180-inp);
  if(k%1 == 0) print('YES');
  else print('NO');
}

var l = parseInt(readline());
for(var i = 0; i < l; ++i)
{
    var a = parseInt(readline());
    var b = 0, n = 3;
    while(8)
    {
        b = 180 - 360/n;
             if(b == a){print("YES"); break;}
        else if(b > a){print("NO"); break;}
        n++;
    }
}

var n = parseInt(readline());
var result ="";
var flag = false;
for(var i=0; i < n; i++){
    var alpha = parseInt(readline());
    flag = false;
    for(var j = 3; j < 65538; j++ ){
        if(alpha == (180/j) * (j-2)) {
            result += 'YES' + '\n';
            flag = true;
            break;
        }
    }
    if(!flag){
        result += 'NO' + '\n';
    }

}

print(result);

;(function () {

	function pu (n) {
		var u = (n - 2)*180 / n;
		return u % 1 ? false : u;
	}

	var n = +readline();
	var us = [];
	var i, j, u;

	for (i = 0; i < n; i++) {
		u = +readline();
		j = 2;

		while (true) {
			j++;
			if (!us[j]) us[j] = pu(j);

			if (us[j]) {
				if (us[j] == u) {
					print('YES');
					break;
				}

				if (us[j] > u) {
					print('NO');
					break;
				}
			}
		}
	}

}).call(this);

var InputReader = (function () {
    function InputReader() {
        this.index = 0;
        this.tokenizer = [];
    }
    InputReader.prototype.next = function () {
        while (this.tokenizer == null || this.index == this.tokenizer.length) {
            this.tokenizer = readline().split(" ");
            this.index = 0;
        }
        var res = this.tokenizer[this.index++];
        return res;
    };
    InputReader.prototype.nextInt = function () {
        return parseInt(this.next());
    };
    InputReader.prototype.nextFloat = function () {
        return parseFloat(this.next());
    };
    return InputReader;
})();
function main() {
    var input = new InputReader();
    var nTest = input.nextInt();
    for (var i = 0; i < nTest; i++) {
        var n = input.nextInt();
        if (360 % (180 - n) == 0) {
            print("YES");
        }
        else {
            print("NO");
        }
    }
}
main();

var n = readline();

	for (var j=0; j<+n; j++){
			var str = readline();
			if ((360/(180-Number(str))%1==0))
			print("YES");
			else 	print("NO");
	}

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

var main = function() {"use strict";
    // TODO
    var t = rdN();
    while (t --> 0) {
        var a = rdN();
        var b = 180 - a;
        pr(360%b === 0 && 360/b > 2 ? 'YES' : 'NO');
    }
};

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

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

var t = parseInt(readline());
for (var i = 0; i < t; i++) {
    var a = 180 - parseInt(readline());
    if (360 % a == 0) print("YES");
    else print("NO")
}

var t=+readline();
while(t--){
	var a=+readline();
	var ans=false;
	for(var i=3; i<100; i++){
		if( 360/i + a/2 === 180-a ){
			ans=true;
			break;
		}
	}
	print(ans?'YES':'NO');
}

var n = parseInt(readline());

for(var i=0; i < n; i++){
    var alpha = parseInt(readline());
    for(var i = 3; i < 65538; i++ ){
        if(alpha == (180/i) * (i-2)){
            print('YES');
        }
    }
    print('NO');
}

var n = parseInt(readline());
var result ="";
for(var i=0; i < n; i++){
    var alpha = parseInt(readline());
    for(var j = 3; i < 65538; i++ ){
        if(alpha == (180/j) * (j-2)){
            result += 'YES' + '\n';
            break;
        }
    }
    result += 'NO' + '\n';
}

print(result);

var n = parseInt(readline());
var result ="";
for(var i=0; i < n; i++){
    var alpha = parseInt(readline());
    for(var i = 3; i < 65538; i++ ){
        if(alpha == (180/i) * (i-2)){
            result += 'YES' + '\n';
        }
    }
    result += 'NO' + '\n';
}

print(result);

var n = parseInt(readline());
var result ="";
for(var i=0; i < n; i++){
    var alpha = parseInt(readline());
    for(var j = 3; j < 65538; j++ ){
        if(alpha == (180/j) * (j-2)){
            result += 'YES' + '\n';
            break;
        }
        result += 'NO' + '\n';
    }

}

print(result);

var n = parseInt(readline());
var result ="";
for(var i=0; i < n; i++){
    var alpha = parseInt(readline());
    for(var j = 3; j < 65538; j++ ){
        if(alpha == (180/j) * (j-2)){
            result += 'YES' + '\n';
            break;
        }
    }
    result += 'NO' + '\n';
}

print(result);


You are given $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$. You choose any subset of the given numbers (possibly, none or all numbers) and negate these numbers (i. e. change $$$x \to (-x)$$$). What is the maximum number of different values in the array you can achieve?

The first line of input contains one integer $$$t$$$ ($$$1 \leq t \leq 100$$$): the number of test cases. The next lines contain the description of the $$$t$$$ test cases, two lines per a test case. In the first line you are given one integer $$$n$$$ ($$$1 \leq n \leq 100$$$): the number of integers in the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-100 \leq a_i \leq 100$$$).

For each test case, print one integer: the maximum number of different elements in the array that you can achieve negating numbers in the array.

NoteIn the first example we can, for example, negate the first and the last numbers, achieving the array $$$[-1, 1, 2, -2]$$$ with four different values.In the second example all three numbers are already different.In the third example negation does not change anything.

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

/***
Good Bye 2021: 2022 is NEAR
2021-12-29

A. Integer Diversity

Lang: Node.js 12.16.3
***/

function main() {
    const t = parseInt(readline());
    for (let i=0; i<t; i++){
        const n = parseInt(readline());
        // Math.abs implicitly casts string to int
        const nums = readline().split(' ').map(x=>Math.abs(x));
        nums.sort();
        let r = 2;
        if (n < 2) {
            r = n;
        } else if (nums[0]===0 && nums[1]===0) {
            r = 1;
        }
        for (let j=2; j<n; j++){
            if (!(nums[j]===nums[j-1] &&
                (nums[j-1]===nums[j-2] || nums[j]===0))) {
                r++;
            }
        }
        console.log(r);
    }
}

let input = "";
process.stdin.on("data", (c) => (input += c));
process.stdin.on("end", () => {
  const { EOL } = require("os");
  const lines = input.split(EOL); /*your input text, split by lines*/
  solveProblem(lines);
});

// const lines = `3
// 4
// 1 1 2 2 2 1 1 -1
// 3
// 1 2 3
// 2
// 0 0`.split("\n");

const solveProblem = (lines) => {
  const lineNumbers = lines
    .slice(2)
    .filter((_, i) => i % 2 === 0)
    .map((line) => line.split(" ").map((x) => +x));

  const result = [];

  for (let i = 0; i < lineNumbers.length; i++) {
    const numbersFound = new Map();
    for (const number of lineNumbers[i]) {
      if (number === 0) {
        numbersFound.set(number, true);
      } else {
        if (numbersFound.has(number)) {
          numbersFound.set(-number, true);
        } else {
          numbersFound.set(number, true);
        }
      }
    }
    result.push(numbersFound.size);
  }

  console.log(result.join("\n"));
};

// solveProblem(lines);

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

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

let nl = nextLine();

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

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

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

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

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

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i =0; i < t; i++){
		nl.num();
		let x = new Set(nl.nums().map((e) => Math.abs(e)).sort().map((e, j) => j%2 == 0?e:-e)).size;
		ans.push(x);
	}
	console.log(ans.join('\n'));
};

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

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader();

function _main() {
  _inputLines = _inputData
    .trim()
    .split("\n")
    .map((string) => {
      return string.trim();
    });

  let t = inputReader.readNumber();

  function solve() {
    let n = inputReader.readNumber();
    let v = inputReader.readNumberArray();
    let arr = new Array(105).fill(0);
    v.forEach((x) => {
      arr[Math.abs(x)] += 1;
    });
    let ans = 0;
    arr.forEach((x, ind, arr) => {
      if (ind == 0) {
        if (x > 0) ans++;
      } else {
        if (x > 1) ans += 2;
        else if (x == 1) ans++;
        else ans += 0;
      }
    });
    console.log(ans);
  }

  while (t--) {
    solve();
  }
}

var _inputData = "";
function cacheInput(data) {
  _inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", cacheInput).on("end", _main);

function _inputReader() {
  function readNumber() {
    return Number(_inputLines[_lineNumber++]);
  }

  function readNumberArray() {
    return _inputLines[_lineNumber++].split(" ").map((val) => Number(val));
  }

  return {
    readNumber,
    readNumberArray,
  };
}

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
    return input[currentline++];
}

var T = readline();
for(var q=1;q<=T;q++) {
    let n = readline();
    let a = readline().split(" ").map(w => parseInt(w))
    var ans = 0;
    var s = [];
    for(var i=0;i<a.length;i++) {
        if(s[a[i]] == undefined) {
            ans++;
            s[a[i]] = true;
        } else {
            var f = (-1)*a[i]
            if(s[f] == undefined) {
                ans++;
                s[f] = true;
            }
        }
    }
    console.log(ans)
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

var maxN = 2 * 1e5 + 10
var mod = BigInt(1e9 + 7)
var map = new Map()
var ans = new Map()

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

  Array(Number(xx)).fill(1).map((t, i) => {
    const n = Number(readline());

    var mark = {}
    for (let j = -100; j <= 100; j++) {
      mark[j] = false
    }
    var a = readline().split(' ').map((x, iii) => {
      if(mark[parseInt(x)] === false) return mark[parseInt(x)] = true
      if(mark[parseInt(x)] === true) mark[-parseInt(x)] = true
      return parseInt(x)
    })
    var count = 0
    for (let j = -100; j <= 100; j++) {
      count+= mark[j] ? 1:0
    }

    console.log(count)

  })
}

function solve(l, r) {
  if (l === r)
    ans[`${l}:${r}`] = l

  for (let i = l; i <= r; i++) {
    if (i === l && map[`${i + 1}:${r}`]) {
      ans[`${l}:${r}`] = i
      solve(i + 1, r)
      break
    } else if (i === r && map[`${l}:${i - 1}`]) {
      ans[`${l}:${r}`] = i
      solve(l, i - 1)
      break

    } else if (map[`${l}:${i - 1}`] && map[`${i + 1}:${r}`]) {
      ans[`${l}:${r}`] = i
      solve(l, i - 1)
      solve(i + 1, r)
      break
    }
  }
}

function check2(q, w, e) {
  if (q === w + e) return true
}

function dec2bin(dec) {
  var string = (dec >>> 0).toString(2);
  var front = ''
  for (let i = 0; i < 20 - string.length; i++) {
    front += '0'
  }
  return (front + string).split("").reverse().join("")
}

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

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => {
        let next;
        do {
            next = (await getLineGen.next());
        } while (!next.done && next.value === '');
        return next.value;
    };
})();

let solve = async () => {
    const nsc = parseInt(await getLine());
    for(let sc = 0; sc < nsc; sc++) {
        const n = parseInt(await getLine());
        const a = (await getLine()).split(' ').map(num => parseInt(num));
        const m = {};
        let res = 0;
        for(let i = 0; i < a.length; i++) {
            const key = Math.abs(a[i]);
            if (!m[key])
                m[key] = 0;
            if ((key !== 0 && m[key] < 2) || (key === 0 && m[key] < 1)) {
                m[key] += 1;
                res += 1;
            }
        }
        console.log(res);
    }
}

solve();

var t = parseInt(readline());

  function solve() {
    var n = parseInt(readline());
    var p = readline()
      .split(" ")
      .map((data) => +data)

    var arr = []

    for (var i = 0; i < n; i++) {
      var val1 = p[i]
      var val2 = -p[i]
      if (!arr.includes(val1)) {
        arr.push(val1)
      } else if (val1 === 0) {
        continue;
      } else if (arr.includes(val1) && arr.includes(val2)) {
        continue;
      } else {
        arr.push(val2)
      }
    }
    return arr.length
  }

  while (t--) {
    print(solve())
  }

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

/***
Good Bye 2021: 2022 is NEAR
2021-12-29

A. Integer Diversity
***/

function main() {
    const t = parseInt(readline());
    for (let i=0; i<t; i++){
        const n = parseInt(readline());
        const nums = readline().split(' ');
        nums.sort();
        let r = 2;
        if (n < 2) {
            r = n;
        } else if (nums[0]==='0' && nums[1]==='0') {
            r = 1;
        }
        for (let j=2; j<n; j++){
            if (!(nums[j]===nums[j-1] &&
                (nums[j-1]===nums[j-2] || nums[j]==='0'))) {
                r++;
            }
        }
        console.log(r);
    }
}

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

/***
Good Bye 2021: 2022 is NEAR
2021-12-29

A. Integer Diversity
***/

function main() {
    const t = parseInt(readline());
    console.log("t="+t);
    for (let i=0; i<t; i++){
        const n = parseInt(readline());
        console.log("n="+n);
        const nums = readline().split(' ');
        console.log("nums="+nums);
        nums.sort();
        let r = 2;
        if (n < 2) {
            r = n;
            console.log('hi A '+r);
        } else if (nums[0]==='0' && nums[1]==='0') {
            r = 1;
            console.log('hi B '+r);
        }
        for (let j=2; j<n; j++){
            if (!(nums[j]===nums[j-1] &&
                (nums[j-1]===nums[j-2] || nums[j]==='0'))) {
                r++;
            }
        }
        console.log(r);
    }
}

let input = "";
process.stdin.on("data", (c) => (input += c));
process.stdin.on("end", () => {
  const { EOL } = require("os");
  const lines = input.split(EOL); /*your input text, split by lines*/
  solveProblem(lines);
});

// const lines = `3
// 4
// 1 1 2 2
// 3
// 1 2 3
// 2
// 0 0`.split("\n");
//

const solveProblem = (lines) => {
  const lineNumbers = lines
    .slice(2)
    .filter((_, i) => i % 2 === 0)
    .map((line) => line.split(" ").map((x) => +x));

  const result = [];

  for (let i = 0; i < lineNumbers.length; i++) {
    const numbersFound = new Map();
    let lineResult = 0;
    for (const number of lineNumbers[i]) {
      if (number === 0) {
        if (!numbersFound.has(number)) {
          lineResult++;
        }
      } else {
        if (!numbersFound.has(number) || numbersFound.get(number) === 1) {
          lineResult++;
        }
      }
      numbersFound.set(number, (numbersFound.get(number) || 0) + 1);
    }
    result.push(lineResult);
  }

  console.log(result.join("\n"));
};

let input = "";
process.stdin.on("data", (c) => (input += c));
process.stdin.on("end", () => {
  const { EOL } = require("os");
  const lines = input.split(EOL); /*your input text, split by lines*/
  solveProblem(lines);
});

// const lines = `3
// 4
// 1 1 2 2
// 3
// 1 2 3
// 2
// 0 0`.split("\n");
//

const solveProblem = (lines) => {
  const lineNumbers = lines
    .slice(2)
    .filter((_, i) => i % 2 === 0)
    .map((line) => line.split(" ").map((x) => +x));

  const result = [];

  for (let i = 0; i < lineNumbers.length; i++) {
    const numbersFound = new Map();
    let lineResult = 0;
    for (const number of lineNumbers[i]) {
      if (number === 0) {
        if (!numbersFound.has(number)) {
          lineResult++;
        }
      } else {
        if (!numbersFound.has(number) || numbersFound.get(number) === 1) {
          lineResult++;
        }
      }
      numbersFound.set(number, (numbersFound.get(number) || 0) + 1);
    }
    result.push(lineResult);
  }

  console.log(result);
};

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

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

let nl = nextLine();

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

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

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

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

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

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i =0; i < t; i++){
		nl.num();
		let x = new Set(nl.nums().sort().map((e, j) => j%2 == 0?e:-e)).size;
		ans.push(x);
	}
	console.log(ans.join('\n'));
};

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

let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader ();

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;

	let t = inputReader.readNumber();

	function solve() {
	  let n = inputReader.readNumber();
	  let v = inputReader.readNumberArray();
	  let arr = new Array(100).fill(0);
	  v.forEach(x => {
	    arr[Math.abs(x)]+=1;
	  });
	  let ans = 0;
	  arr.forEach((x, ind, arr)=>{
	    if(ind!=0) ans+=2*(x/2);
	    else {
	      if(x > 0)
	      ans+=1;
	    }
	  });
	  console.log(ans);
	}

	while (t--) {
	  solve();
	}

}

var _inputData = '';
function cacheInput(data) {
	_inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', cacheInput).on('end', _main);

function _inputReader () {
	function readNumber(){
		return Number(_inputLines[_lineNumber++]);
	}

	function readNumberArray(){
		return _inputLines[_lineNumber++].split(' ').map(val => Number(val));
	}

	return {
		readNumber,
		readNumberArray,
	}
}


One day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games. Alex enjoyed playing Minesweeper that time. He imagined that he saved world from bombs planted by terrorists, but he rarely won.Alex has grown up since then, so he easily wins the most difficult levels. This quickly bored him, and he thought: what if the computer gave him invalid fields in the childhood and Alex could not win because of it?He needs your help to check it.A Minesweeper field is a rectangle $$$n \times m$$$, where each cell is either empty, or contains a digit from $$$1$$$ to $$$8$$$, or a bomb. The field is valid if for each cell:   if there is a digit $$$k$$$ in the cell, then exactly $$$k$$$ neighboring cells have bombs.  if the cell is empty, then all neighboring cells have no bombs. Two cells are neighbors if they have a common side or a corner (i. e. a cell has at most $$$8$$$ neighboring cells).

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 100$$$) — the sizes of the field. The next $$$n$$$ lines contain the description of the field. Each line contains $$$m$$$ characters, each of them is "." (if this cell is empty), "*" (if there is bomb in this cell), or a digit from $$$1$$$ to $$$8$$$, inclusive.

Print "YES", if the field is valid and "NO" otherwise. You can choose the case (lower or upper) for each letter arbitrarily.

NoteIn the second example the answer is "NO" because, if the positions of the bombs are preserved, the first line of the field should be *2*1.You can read more about Minesweeper in Wikipedia's article.

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

const lines = [];
rl.on('line', (line) => {
    lines.push(line);
}).on('close', () => {
    let dims = lines[0];
    dims = dims.split(' ').map(Number);
    const n = dims[0], m = dims[1];

    const rows = [];
    let isGridValid = true;

    function numerize(x) {
        return isNaN(Number(x)) ? x : Number(x);
    }

    function isCellValid(y, x) {
        const cell = rows[y][x];
        if (!cell) {
            return false;
        }

        let bombs = 0;
        for (let i = y - 1; i <= y + 1; i++) {
            if (!rows[i]) {
                continue;
            }
            for(let j = x - 1; j <= x + 1; j++) {
                if (rows[i][j] && rows[i][j] === '*') {
                    bombs++;
                }
            }
        }

        if (typeof cell === 'number') {
            return bombs === cell;
        }

        return cell === '.' ? bombs === 0 : true;
    }

    for (let i = 1; i <= n; i++) {
        var row = lines[i].split('').map(numerize);
        rows.push(row);
    }

    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            isGridValid = isCellValid(i, j);
            if (!isGridValid) {
                break;
            }
        }
        if (!isGridValid) {
            break;
        }
    }

    process.stdout.write(isGridValid ? 'YES' : 'NO');
});

var vals = readline().split(" ");
var n = parseInt(vals[0]);
var m = parseInt(vals[1]);
var fil = [];

for (var i = 1; i < n + 1; i++) {
  fil[i] = readline().split("")
  .map(function(el) {
    if (el === '.') {
      return 0;
    } else if (el === '*') {
      return 100;
    } else {
      return el;
    }
  })
  .map(function(el) {
    return parseInt(el);
  });
  fil[i].unshift(0);
  fil[i].push(0);
}

fil[0] = [];
fil[n+1] = [];
for (var j = 0; j < m + 2; j++) {
  fil[0].push(0);
  fil[n+1].push(0);
}

function calc(n, m, fil) {
  var sum;
  for (var i = 1; i < n + 1; i++) {
    for (var j = 1; j < m + 1; j++) {
      sum = fil[i-1][j-1] + fil[i][j-1] + fil[i+1][j-1] + fil[i-1][j] + fil[i+1][j] + fil[i-1][j+1] + fil[i][j+1] + fil[i+1][j+1];
      if (fil[i][j] !== 100 && Math.floor(sum / 100) !==  fil[i][j]) {
        print('NO');
        return;
      }
    }
  }
  print('YES');
}

calc(n,m,fil);

l = readline().split(' ');
n = +l[0], m = +l[1];
a = [];
for (i = 0; i < n; i++)
  a.push(readline());
dr = [-1, -1, 0, 1, 1, 1, 0, -1], dc = [0, 1, 1, 1, 0, -1, -1, -1];
function Bombs_Around(i, j) {
  ans = 0;
  for (k = 0; k < 8; k++) {
    ix = i + dr[k], jx = j + dc[k];
    if (ix < 0 || ix >= n || jx < 0 || jx >= m)
      continue;
    if (a[ix].charAt(jx) === '*')
      ans++;
  }
  return ans;
}
function Solve() {
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      cur = a[i].charAt(j);
      if (cur === '*')
        continue;
      bombs = Bombs_Around(i, j);
      if (cur === '.') {
        if (bombs > 0)
          return false;
      }
      else if (bombs != parseInt(cur))
        return false;
    }
  return true;
}
print(Solve() ? 'YES' : 'NO');

var dims = readline();
dims = dims.split(' ').map(Number);
var n = dims[0], m = dims[1];

var rows = [];
var isGridValid = true;

function numerize(x) {
    return isNaN(Number(x)) ? x : Number(x);
}

function isCellValid(y, x) {
    var cell = rows[y][x];
    if (!cell) {
        return false;
    }

    var bombs = 0;
    for (var i = y - 1; i <= y + 1; i++) {
        if (!rows[i]) {
            continue;
        }
        for(var j = x - 1; j <= x + 1; j++) {
            if (rows[i][j] && rows[i][j] === '*') {
                bombs++;
            }
        }
    }

    if (typeof cell === 'number') {
        return bombs === cell;
    }

    return cell === '.' ? bombs === 0 : true;
}

for (var i = 0; i < n; i++) {
    var row = readline().split('').map(numerize);
    rows.push(row);
}

for (var i = 0; i < n; i++) {
    for (var j = 0; j < m; j++) {
        isGridValid = isCellValid(i, j);
        if (!isGridValid) {
            break;
        }
    }
    if (!isGridValid) {
        break;
    }
}

print(isGridValid ? 'YES' : 'NO');

var p = readline().split(' ').map(Number);
var n = p[0];
var m = p[1];
var saper = [];
var ans = 'YES';
for (var i=0; i<n+2; i++){
	saper[i] = [];
	for (var j=0; j<m+2; j++){
		saper[i][j] = +0;
	}
}
for (var i=1; i<n+1; i++){
	var str = readline().split('');
	for (var j=1; j<m+1; j++){
		if (str[j-1] == '*') saper[i][j] = '*';
		else if (str[j-1] == '.') saper[i][j] = +0;
		else saper[i][j] = +str[j-1];
	}
}
for (var i=1; i<n+1; i++){
	for (var j=1; j<m+1; j++){
		if (saper[i][j] != '*') {
			var count = 0;
			if (saper[i-1][j-1] == '*') count++;
			if (saper[i-1][j] == '*') count++;
			if (saper[i-1][j+1] == '*') count++;
			if (saper[i][j-1] == '*') count++;
			if (saper[i][j+1] == '*') count++;
			if (saper[i+1][j-1] == '*') count++;
			if (saper[i+1][j] == '*') count++;
			if (saper[i+1][j+1] == '*') count++;
			print (count);
			if (saper[i][j] != count) ans = 'NO';
		}
	}
}
print (ans);

var dims = readline();
dims = dims.split(' ').map(Number);
var n = dims[0], m = dims[1];

var rows = [];
var isGridValid = true;

function numerize(x) {
    return isNaN(Number(x)) ? x : Number(x);
}

function isCellValid(x, y, cell) {
    var bombs = 0;
    for (var i = y - 1; i <= y + 1; i++) {
        if (!rows[i]) {
            continue;
        }
        for(var j = x - 1; j <= x + 1; j++) {
            if (rows[i][j] && rows[i][j] === '*') {
                bombs++;
            }
        }
    }

    if (typeof cell === 'number') {
        return bombs === cell;
    }

    return cell === '.' ? bombs === 0 : true;
}

for (var i = 0; i < n; i++) {
    var row = readline().split('').map(numerize);
    rows.push(row);
}

for (var i = 0; i < n; i++) {
    for (var j = 0; j < m; j++) {
        isGridValid = isCellValid(j, i, rows[i][j]);
        if (!isGridValid) {
            break;
        }
    }
}

print(isGridValid ? 'YES' : 'NO');


A bitstring is a string that contains only the characters 0 and 1.Koyomi Kanou is working hard towards her dream of becoming a writer. To practice, she decided to participate in the Binary Novel Writing Contest. The writing prompt for the contest consists of three bitstrings of length $$$2n$$$. A valid novel for the contest is a bitstring of length at most $$$3n$$$ that contains at least two of the three given strings as subsequences.Koyomi has just received the three prompt strings from the contest organizers. Help her write a valid novel for the contest.A string $$$a$$$ is a subsequence of a string $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero) characters.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$). Each of the following three lines contains a bitstring of length $$$2n$$$. It is guaranteed that these three strings are pairwise distinct. It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$10^5$$$.

For each test case, print a single line containing a bitstring of length at most $$$3n$$$ that has at least two of the given bitstrings as subsequences. It can be proven that under the constraints of the problem, such a bitstring always exists. If there are multiple possible answers, you may output any of them.

NoteIn the first test case, the bitstrings 00 and 01 are subsequences of the output string: 010 and 010. Note that 11 is not a subsequence of the output string, but this is not required.In the second test case all three input strings are subsequences of the output string: 011001010, 011001010 and 011001010.

var readline = require('readline');

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

function solve(a, b, c) {
    const n = a.length / 2
    const a1 = count(a, '1')
    const b1 = count(b, '1')
    const c1 = count(c, '1')

    if (a1 >= n) {
        if (b1 >= n) {
            return merge(a, b, '1')
        } else {
            return c1 >= n ? merge(a, c, '1') : merge(b, c, '0')
        }
    } else {
        if (b1 < n) {
            return merge(a, b, '0')
        } else {
            return c1 < n ? merge(a, c, '0') : merge(b, c, '1')
        }
    }
}
function count(a, ch) {
    let c = 0
    for (let i = 0; i < a.length; i++) {
        if (a[i] === ch) c++
    }
    return c
}
function merge(a, b, ch) {
    let i = 0
    let j = 0
    let k = 0
    const r = []
    while (i < a.length && j < b.length) {
        if (a[i] === b[j]) {
            r[k++] = a[i++]
            j++
        } else if (a[i] === ch) {
            r[k++] = b[j++]
        } else {
            r[k++] = a[i++]
        }
    }
    while (i < a.length) r[k++] = a[i++]
    while (j < b.length) r[k++] = b[j++]
    return r.join('')
}


You are given an array $$$a$$$ of $$$n$$$ elements. Your can perform the following operation no more than $$$n$$$ times: Select three indices $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$ and replace $$$a_x$$$ with $$$a_y - a_z$$$. After the operation, $$$|a_x|$$$ need to be less than $$$10^{18}$$$.Your goal is to make the resulting array non-decreasing. If there are multiple solutions, you can output any. If it is impossible to achieve, you should report it as well.

Each test contains multiple test cases. The first line will contain a single integer $$$t$$$ $$$(1 \leq t \leq 10000)$$$ — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ $$$(3 \leq n \leq 2 \cdot 10^5)$$$ — the size of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots ,a_n$$$ $$$(-10^9 \leq a_i \leq 10^9)$$$, the elements of $$$a$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print $$$-1$$$ in a single line if there is no solution. Otherwise in the first line you should print a single integer $$$m$$$ $$$(0 \leq m \leq n)$$$ — number of operations you performed. Then the $$$i$$$-th of the following $$$m$$$ lines should contain three integers $$$x,y,z$$$ $$$(1 \leq x < y < z \leq n)$$$— description of the $$$i$$$-th operation. If there are multiple solutions, you can output any. Note that you don't have to minimize the number of operations in this task.

NoteIn the first example, the array becomes $$$[-6,-4,2,-1,2]$$$ after the first operation,$$$[-6,-4,-3,-1,2]$$$ after the second operation.In the second example, it is impossible to make the array sorted after any sequence of operations.In the third example, the array is already sorted, so we don't need to perform any operations.

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
    let t = parseInt(readline())
    while(t--){
        let n = parseInt(readline())
        let k = readline().split(" ")
        let v = []
        for(let i in k) v.push(parseInt(k[i]))
        if(v[n-2] > v[n-1]){
            console.log(-1)
        }else{
            let i = n-3
            let ct = 0
            let a = new Array(n).fill(false)
            while(i>=0){
                if(v[i] > v[i+1]){
                    ct++
                    v[i] = v[i+1] - v[n-1]
                    a[i] = true
                }
                i--
            }
            let flag = true
            for(let i = 1;i<n;i++){
                if(v[i]<v[i-1]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                let i = n-3
                console.log(ct)
                while(i>=0){
                    if(a[i]){
                        console.log(`${i+1} ${i+2} ${n}`)
                    }
                    i--;
                }
            }else console.log(-1)
        }
    }

}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
    let t = parseInt(readline())
    while(t--){
        let n = parseInt(readline())
        let v = readline().split(" ")
        if(parseInt(v[n-2]) > parseInt(v[n-1])){
            console.log(-1)
        }else{
            let i = n-3
            let ct = 0
            let a = new Array(n).fill(false)
            while(i>=0){
                if(parseInt(v[i]) > parseInt(v[i+1])){
                    ct++
                    v[i] = v[i+1] - v[n-1]
                    a[i] = true
                }
                i--
            }
            let flag = true
            for(let i = 1;i<n;i++){
                if(parseInt(v[i])<parseInt(v[i-1])){
                    flag = false;
                    break;
                }
            }
            if(flag){
                let i = n-3
                console.log(ct)
                while(i>=0){
                    if(a[i]){
                        console.log(`${i+1} ${i+2} ${n}`)
                    }
                    i--;
                }
            }else console.log(-1)
        }
    }

}

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

const rl = () => stdin_input_itr.next().value;
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();

		let ok = true;
		for (let i = 0; i < n-1; i++) {
			if (a[i] > a[i+1]) ok = false;
		}

		if (ok) {
			console.log(0);
		} else if (a[n-2] <= a[n-1] && a[n-1] >= 0) {
			console.log(n-2);
			for (let i = 0; i < n-2; i++) {
				console.log(i+1, n-1, n);
			}
		} else {
			console.log(-1);
		}
	}
}

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

const rl = () => stdin_input_itr.next().value;
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();

		let ok = true;
		for (let i = 1; i < n; i++) {
			ok = ok && a[i-1] <= a[i];
		}

		if (ok) {
			console.log(0);
		} else if (a[a.length-2] <= a[a.length-1] && a[a.length-1] >= 0) {
			console.log(n-2);
			for (let i = 0; i < n-2; i++) {
				console.log(i+1, n-1, n);
			}
		} else {
			console.log(-1);
		}
	}
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let n = parseInt(readline());
    let arr = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    const check = (arr) => {
      for (let i = 1; i < arr.length; i++)
        if (arr[i - 1] > arr[i]) return false;
      return true;
    };
    if (check(arr)) {
      console.log(0);
      continue;
    }
    if (arr[n - 1] < 0 && arr[n - 2] < 0) {
      console.log(-1);
      continue;
    }
    if (arr[n - 1] < arr[n - 2]) {
      console.log(-1);
      continue;
    }
    let o = n - 3;
    let k = o;
    console.log(o + 1);
    while (o >= 0) {
      console.log(`${o + 1} ${k + 2} ${k + 3}`);
      o--;
    }
  }
};
solve();

'use strict';

function solve(n, a) {
  const dif = new Array(n);
  let max = n - 1;
  for (let i = n - 2; i >= 0; i--) {
    var _dif$, _dif;
    const cur = a[i] - a[max];
    if (cur < ((_dif$ = (_dif = dif[i + 1]) === null || _dif === void 0 ? void 0 : _dif[0]) !== null && _dif$ !== void 0 ? _dif$ : Infinity)) {
      dif[i] = [cur, i, max];
    } else {
      dif[i] = [...dif[i + 1]];
    }
    if (a[i] > a[max]) max = i;
  }
  const nums = new Array(n),
        res = [];
  nums[n - 1] = a[n - 1];
  nums[n - 2] = a[n - 2];
  for (let i = 0; i < n - 2; i++) {
    nums[i] = dif[i + 1][0];
    if (nums[i] < a[i]) res.push([i, dif[i + 1][1], dif[i + 1][2]]);else nums[i] = a[i];
  }
  for (let i = 0; i < n - 1; i++) {
    if (nums[i] > nums[i + 1]) return -1;
  }
  if (res.length) return `${res.length}\n${res.map(arr => arr.map(num => num + 1).join(' ')).join('\n')}`;
  return 0;
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
    let t = parseInt(readline())
    while(t--){
        let n = parseInt(readline())
        let k = readline().split(" ")
        let v = []
        for(let i in k) v.push(parseInt(v[i]))
        if(parseInt(v[n-2]) > parseInt(v[n-1])){
            console.log(-1)
        }else{
            let i = n-3
            let ct = 0
            let a = new Array(n).fill(false)
            while(i>=0){
                if(v[i] > v[i+1]){
                    ct++
                    v[i] = v[i+1] - v[n-1]
                    a[i] = true
                }
                i--
            }
            let flag = true
            for(let i = 1;i<n;i++){
                if(v[i]<v[i-1]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                let i = n-3
                console.log(ct)
                while(i>=0){
                    if(a[i]){
                        console.log(`${i+1} ${i+2} ${n}`)
                    }
                    i--;
                }
            }else console.log(-1)
        }
    }

}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
    let t = parseInt(readline())
    while(t--){
        let n = parseInt(readline())
        let v = readline().split(" ")
        if(parseInt(v[n-2]) > parseInt(v[n-1])){
            console.log(-1)
        }else{
            let i = n-3
            let ct = 0
            let a = new Array(n).fill(false)
            while(i>=0){
                if(v[i] > v[i+1]){
                    ct++
                    v[i] = v[i+1] - v[n-1]
                    a[i] = true
                }
                i--
            }
            let flag = true
            for(let i = 1;i<n;i++){
                if(v[i]<v[i-1]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                let i = n-3
                console.log(ct)
                while(i>=0){
                    if(a[i]){
                        console.log(`${i+1} ${i+2} ${n}`)
                    }
                    i--;
                }
            }else console.log(-1)
        }
    }

}

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

function print(x) {
  console.log(x);
}
let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});
function readline() {
  return inputString[currentLine++];
}

// ********** Code Start **********

function main() {
    let t = parseInt(readline())
    while(t--){
        let n = parseInt(readline())
        let v = readline().split(" ")
        if(parseInt(v[n-2]) > parseInt(v[n-1])){
            console.log(-1)
        }else{
            let i = n-3
            let ct = 0
            let a = new Array(n).fill(false)
            while(i>=0){
                if(v[i] > v[i+1]){
                    ct++
                    v[i] = v[i+1] - v[n-1]
                    a[i] = true
                }
                i--
            }
            let flag = true
            for(let i = 1;i<n;i++){
                if(v[i]<v[i-1]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                let i = n-3
                console.log(ct)
                while(i>=0){
                    if(a[i]){
                        console.log(`${i} ${i+1} ${n-1}`)
                    }
                    i--;
                }
            }else console.log(-1)
        }
    }

}

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

const rl = () => stdin_input_itr.next().value;
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();

		if (a[a.length-2] > a[a.length-1]) {
			console.log(-1);
		} else {
			console.log(n-2);
			for (let i = 0; i < n-2; i++) {
				console.log(i+1, n-1, n);
			}
		}
	}
}

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

const rl = () => stdin_input_itr.next().value;
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();

		if (a[a.length-2] > a[a.length-1]) {
			console.log(-1);
		} else {
			console.log(n-2);
			for (let i = 0; i < n-2; i++) {
				console.log(i+1, n-1, n-2);
			}
		}
	}
}