Polycarp has a string $$$s$$$ consisting of lowercase Latin letters.He encodes it using the following algorithm.He goes through the letters of the string $$$s$$$ from left to right and for each letter Polycarp considers its number in the alphabet:  if the letter number is single-digit number (less than $$$10$$$), then just writes it out;  if the letter number is a two-digit number (greater than or equal to $$$10$$$), then it writes it out and adds the number 0 after. For example, if the string $$$s$$$ is code, then Polycarp will encode this string as follows:  'c' — is the $$$3$$$-rd letter of the alphabet. Consequently, Polycarp adds 3 to the code (the code becomes equal to 3);  'o' — is the $$$15$$$-th letter of the alphabet. Consequently, Polycarp adds 15 to the code and also 0 (the code becomes 3150);  'd' — is the $$$4$$$-th letter of the alphabet. Consequently, Polycarp adds 4 to the code (the code becomes 31504);  'e' — is the $$$5$$$-th letter of the alphabet. Therefore, Polycarp adds 5 to the code (the code becomes 315045). Thus, code of string code is 315045.You are given a string $$$t$$$ resulting from encoding the string $$$s$$$. Your task is to decode it (get the original string $$$s$$$ by $$$t$$$).

The first line of the input contains an integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of test cases in the input. The descriptions of the test cases follow. The first line of description of each test case contains one integer $$$n$$$ ($$$1 \le n \le 50$$$) — the length of the given code. The second line of the description of each test case contains a string $$$t$$$ of length $$$n$$$ — the given code. It is guaranteed that there exists such a string of lowercase Latin letters, as a result of encoding which the string $$$t$$$ is obtained.

For each test case output the required string $$$s$$$ — the string that gives string $$$t$$$ as the result of encoding. It is guaranteed that such a string always exists. It can be shown that such a string is always unique.

code
aj
abacaba
ll
codeforces
aaaak
aaaaj
aaaaa
zf

NoteThe first test case is explained above.In the second test case, the answer is aj. Indeed, the number of the letter a is equal to $$$1$$$, so 1 will be appended to the code. The number of the letter j is $$$10$$$, so 100 will be appended to the code. The resulting code is 1100.There are no zeros in the third test case, which means that the numbers of all letters are less than $$$10$$$ and are encoded as one digit. The original string is abacaba.In the fourth test case, the string $$$s$$$ is equal to ll. The letter l has the number $$$12$$$ and is encoded as 120. So ll is indeed 120120.

    var limit = parseInt(readline());
    var alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
                    'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
                    'w', 'x', 'y', 'z'];
    for (var i = 0; i < limit; i++)
    {
        var codeLength = parseInt(readline()) - 1;
        var codeNum = readline();
        var result = "";
        while (codeLength >= 0)
        {
            var current = parseInt(codeNum[codeLength]);
            if (current !== 0)
            {
                result = alphabets[current-1] + result;
            }
            else
            {
                codeLength -= 2;
                var newCodeNum = codeNum[codeLength] + codeNum[codeLength+1];
                var newCurrent = parseInt(newCodeNum);
                result = alphabets[newCurrent-1] + result;
            }
            codeLength--;
        }
        print(result);
    }

function numberToLetter(num) {
	return (num + 9).toString(36)
}

function foo(str) {

  	var i = 0
    var result = ''

    while(i < str.length) {
    	if(str[i + 2] === '0' && str[i + 3] !== '0') {
          result += numberToLetter(Number(str[i] + str[i+1]))
          i += 3
        }
      	else {
        	result += numberToLetter(Number(str[i]))
          	i++
        }
    }

  	return result
}

var count = readline();

var inp;
var size;

for(var i = 0 ; i < count ; i++) {
    readline();
    inp = readline();
    print(foo(inp));

}

var t = +readline()

for (var i=0; i<t; i++) {

    var str_len = readline()
    var str = readline()

    var j = str.length - 1
    var ans = ""
    var ref = "0abcdefghijklmnopqrstuvwxyz"

    while (j >= 0) {
        var num = str[j]
        if (str[j] == "0") {
            num = Number(str[j-2] + str[j-1])
            j -= 2
        }
        j--
        var char = ref[num]
        ans = char + ans
    }
    print(ans)
}

var t = +readline();

for(var i = 0; i< t; i ++) {

      var nums = [];
    var arr = readline()
    var str = readline()
    print(TwoElevators(str))

}

function TwoElevators(str){
       var list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];

    var newstr = '';

    for(var i = str.length -1; i >= 0; i--){
        if (str[i] == '0'){
            var num = str[i-2] + str[i-1]
            newstr = list[+num-1] + newstr;
            i -= 2
        }else {
            var num2 = str[i]
            newstr = list[+num2-1] + newstr;
        }
    }

    return newstr;
}

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

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", (_) => {
  inputString = inputString.trim().split("\n").map((string) => {
    return string.trim();
  });
  main();
});
function readline() {
  return inputString[currentLine++];
}
function main() {
  let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
  let n = readline();
  for (let k = 0; k < n; k++) {
    var o = readline();
    var splittedSTR = readline().trim().split('');
    var output = [];
    for (var i = 0; i < o; i++) {
      if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
        splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
        splittedSTR.splice(i + 1, 1)
        splittedSTR.splice(i - 1, 1)
      }
      if (o - i == 1) {
        for (var j = 0; j < splittedSTR.length; j++) {
          output.push(Alpha[splittedSTR[j] - 1])
          if (output.length == splittedSTR.length) {
            console.log(output.join(''));
          }
        }
      }
    }
  }
}

"use strict";

const fs = require("fs");
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

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

/*
 * Complete the 'decodeString' function below.
 *
 * The function is expected to return an INTEGER.
 * The function accepts 2D_INTEGER_ARRAY arr as parameter.
 */

function decodeString(arr) {
  // Write your code here
  const dict = [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
    "z",
  ];

  for (let i = 0; i < arr.length; i++) {
    const string = arr[i].toString().split("");
    const stringLength = string.length;
    let text = "";
    let j = 0;
    while (j < string.length) {
      let posPlus2 = string[j + 2];
      let posPlus3 = string[j + 3];
      if (
        j + 2 < stringLength &&
        Number(posPlus2) === 0 &&
        ((j + 3 < stringLength && Number(posPlus3) !== 0) ||
          j + 3 >= stringLength)
      ) {
        const pos = string[j] + string[j + 1];
        text += dict[Number(pos - 1)];

        j += 3;
      } else {
        const pos = string[j];
        text += dict[Number(pos - 1)];
        j += 1;
      }
    }
    console.log(text);
  }
}

function main() {
  const n = parseInt(readLine().trim());
  let arr = Array(n);
  for (let i = 0; i < n * 2; i++) {
    let text = readLine().replace(/\s+$/g, "").split(" ");
    if (i % 2 === 1) {
      arr[Math.floor(i / 2)] = text.map((arrTemp) => arrTemp.toString())[0];
    }
  }

  const result = decodeString(arr);
}

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

let currentLine = 0;
let inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

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

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

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

function readArrayInt() {
  return inputString[currentLine++].split(" ").map(Number);
}

function readArray() {
  return inputString[currentLine++].split(" ");
}

function main() {
  const T = readInt();

  for (let i = 0; i < T; ++i) {
    const n = readInt();
    const str = readString();

    let count = 0;
    let ans = "";
    let asd = 0;
    while (count < n) {
      //   console.log(str.slice(count + 2, count + 4), "(((((((((");
      if (str.slice(count + 2, count + 4) == "00") {
        asd = str[count];
        count++;
      } else if (count < n - 2 && str[count + 2] == "0") {
        asd = str.slice(count, count + 2);
        count += 2;
      } else {
        asd = str[count];
        count++;
      }

      ans += String.fromCharCode(+asd + 96);
      ans = ans.replace("`", "");
      //   console.log(asd, String.fromCharCode(+asd + 96), "after");
    }
    console.log(ans);
  }
}

"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 alphabet = "abcdefghijklmnopqrstuvwxyz";
  let arr = [];
  let TC = readline();
  for (let m = 0; m < TC; m++) {
    let res = "";
    let stringLeng = readline();
    let str = "" + readline();
    for (let i = stringLeng - 1; i + 1; i--) {
      if (str[i] != 0) res += alphabet[str[i] - 1];
      else {
        let jam = str[i - 1] + str[i - 2];
        jam = jam.split("").reverse().join("");
        res += alphabet[jam - 1];
        i--;
        i--;
      }
    }
    res = res.split("").reverse().join("");
    arr.push(res);
  }
  arr = arr.join("\n");
  console.log(arr);
}

// Author: shubh_singh
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let currentLine = 0;
let inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

process.stdin.on("end", (_) => {
  if(!inputString) {
    console.warn("Input file is empty.");
    return;
  }
  inputString = inputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

readInt = () => {
  return Number(inputString[currentLine++]);
}

readString = () => {
  return inputString[currentLine++];
}

readArrayInt = () => {
  return inputString[currentLine++].split(" ").map(Number);
}

readArray = () => {
  return inputString[currentLine++].split(" ");
}

// Solve
solve = () => {
  let n = readInt();
  let s = readString();
  let i = n-1;
  let res = "";
  while(i >= 0) {
    if(s[i] == '0') {
      let val = parseInt(s[i-2]+s[i-1]);
      let code = String.fromCharCode(val+96);
      res += code;
      i -= 3;
    }else {
      let code = String.fromCharCode(parseInt(s[i])+96);
      res += code;
      i--;
    }
  }

  console.log(res.split("").reverse().join(""));
}

main = () => {
    let t = readInt();
    while(t--)
      solve();
}

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

  main();
});

function main() {
  const testCases = inputString[0];

  for (let i = 2; i <= testCases * 2; i += 2) {
    const nums = inputString[i].split("").map((s) => Number(s));

    const answer = nums
      .reduce((acc, cur, ix, arr) => {
        if (cur === 0 && arr[ix + 1] !== 0) {
          const n = Number(acc[acc.length - 2] + "" + acc[acc.length - 1]);
          acc = acc.slice(0, -2);
          acc.push(n);
        } else acc.push(cur);

        return acc;
      }, [])
      .map((n) => String.fromCharCode(n + 96))
      .join("");

    console.log(answer);
  }
}

/*
** Template
*/

// Common Template Starts //
//*
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Common Template Ends //

const getDictionary = () => {
    let dict = []
    for (let i = 1; i <= 26; i++) {
        let d = {
            'letter': String.fromCharCode(97 + (i - 1)),
            'value': i,
        }
        dict.push(d)
    }

    return dict
}

function getResult(n, enc, dict) {
    let dec = ''

    enc = enc.split('').map(Number)

    if (n == 1) return dict.find(r => r.value == enc[0])['letter']
    if (n == 2) return dict.find(r => r.value == enc[0])['letter'] + dict.find(r => r.value == enc[1])['letter']

    let dis = []

    let i = n - 1
    while (i >= 0) {
        if (enc[i] != 0) dis.push(enc[i].toString())
        else {
            let temp = ''
            let j = i - 1
            while (j >= (i - 2)) {
                temp += enc[j].toString()
                j--
            }
            dis.push(temp.split('').reverse().join(''))
            i = j + 1
        }
        i--
    }

    dis.reverse().forEach(d => {
        dec += dict.find(r => r.value == parseInt(d))['letter']
    })

    return dec
}

function main() {
let dict = getDictionary()
    let testCases = parseInt(readline())
    while (testCases--) {
        let n = parseInt(readline())
        let enc = readline()
        console.log( getResult(n, enc, dict) )
    }
}

//*/

// console.clear()
// let n = 0
// let enc = 0
// let dict = getDictionary()

// n = 6
// enc = '315045'
// console.log( getResult(n, enc, dict) )

// n = 4
// enc = '1100'
// console.log( getResult(n, enc, dict) )

// n = 7
// enc = '1213121'
// console.log( getResult(n, enc, dict) )

// n = 6
// enc = '120120'
// console.log( getResult(n, enc, dict) )

// n = 18
// enc = '315045615018035190'
// console.log(getResult(n, enc, dict))

// n = 7
// enc = '1111110'
// console.log( getResult(n, enc, dict) )

// n = 7
// enc = '1111100'
// console.log( getResult(n, enc, dict) )

// n = 5
// enc = '11111'
// console.log( getResult(n, enc, dict) )

// n = 4
// enc = '2606'
// console.log( getResult(n, enc, dict) )

// process.exit(1)

const readline = require('readline')

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

function solve(n, str) {
    let i = n - 1
    const r = []
    while (i >= 0) {
        if (str[i] === '0') {
            r.unshift(ch(+str.slice(i - 2, i)))
            i -= 3
        } else {
            r.unshift(ch(+str[i]))
            i--
        }
    }
    return r.join('')
}
function ch(i) {
    const a = 'a'.charCodeAt(0)
    return String.fromCharCode(a + i - 1)
}

'use strict';

var fs = require('fs');

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

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const rn = () => Number(read());
  const n = rn();
  const s = read();
  let res = [];
  for (let i = n - 1; i >= 0; i--) {
    if (s[i] === '0') {
      res.push(String.fromCharCode(Number(s.slice(i - 2, i)) + 96));
      i -= 2;
    } else {
      res.push(String.fromCharCode(Number(s.slice(i, i + 1)) + 96));
    }
  }
  return res.reverse().join('');
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'], z = -1, f;
process.stdin.on('data', function (data) {
  var splittedSTR = data.toString().trim().split('')
  let output = [];
  if (splittedSTR.length == 1) {
    if (f == undefined) {
      f = data.toString().trim();
    } else {
    }
    return;
  }
  for (var i = 0; i < splittedSTR.length; i++) {
    if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
      splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
      splittedSTR.splice(i + 1, 1)
      splittedSTR.splice(i - 1, 1)
    }
  }
  for (var i = 0; i < splittedSTR.length; i++) {
    output.push(Alpha[splittedSTR[i] - 1])
    if (output.length == splittedSTR.length) {
      console.log(output.join(''));
      z++
      if (z == f) {
        process.exit();
      }
    }
  }
})

let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'], z = 0, f;
process.stdin.on('data', function (data) {
  var splittedSTR = data.toString().trim().split('')
  let output = [];
  if (splittedSTR.length == 1) {
    if (f == undefined) {
      f = data.toString().trim();
    } else {
    }
    return;
  }
  for (var i = 0; i < splittedSTR.length; i++) {
    if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
      splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
      splittedSTR.splice(i + 1, 1)
      splittedSTR.splice(i - 1, 1)
    }
  }
  for (var i = 0; i < splittedSTR.length; i++) {
    output.push(Alpha[splittedSTR[i] - 1])
    if (output.length == splittedSTR.length) {
      console.log(output.join(''));
      z++
      console.log(z, f);
    }
  }
  if (z == (f + 1)) {
    console.log('obj');
    process.exit();
  }
})

let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
process.stdin.on('data', function (data) {
  var splittedSTR = data.toString().trim().split('')
  let output = [];
  if (splittedSTR.length == 1) {
    return;
  }
  for (var i = 0; i < splittedSTR.length; i++) {
    if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
      splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
      splittedSTR.splice(i + 1, 1)
      splittedSTR.splice(i - 1, 1)
    }
  }
  for (var i = 0; i < splittedSTR.length; i++) {
    output.push(Alpha[splittedSTR[i] - 1])
    if (output.length == splittedSTR.length) {
      console.log(output.join(''));
    }
  }
})

let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
process.stdin.on('data', function (data) {
  var splittedSTR = data.toString().trim().split('')
  if (data.length == 1) data = data.toString().trim();
  let output = [];
  for (var i = 0; i < data; i++) {
    if (i == 0) {}
    else if (i % 2 == 0) {}
    else {
      for (var i = 0; i < splittedSTR.length; i++) {
        if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
          splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
          splittedSTR.splice(i + 1, 1)
          splittedSTR.splice(i - 1, 1)
        }
      }
      for (var i = 0; i < splittedSTR.length; i++) {
        output.push(Alpha[splittedSTR[i] - 1])
        if (output.length == splittedSTR.length) {
          console.log(output.join(''));
        }
      }
    }
  }
})

let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
process.stdin.on('data', function (data) {
  var splittedSTR = data.toString().trim().split('')
  if (data.length == 1) data = data.toString().trim();
  let output = [];
  for (var i = 0; i < data; i++) {
    if (i == 0) {}
    else if (i % 2 != 0) {}
    else {
      for (var i = 0; i < splittedSTR.length; i++) {
        if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
          splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
          splittedSTR.splice(i + 1, 1)
          splittedSTR.splice(i - 1, 1)
        }
      }
      for (var i = 0; i < splittedSTR.length; i++) {
        output.push(Alpha[splittedSTR[i] - 1])
        if (output.length == splittedSTR.length) {
          console.log(output.join(''));
        }
      }
    }
  }
})

let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
process.stdin.on('data', function (data) {
  var splittedSTR = data.toString().trim().split('')
  let output = []
  for (var i = 0; i < splittedSTR.length; i++) {
    if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
      splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
      splittedSTR.splice(i + 1, 1)
      splittedSTR.splice(i - 1, 1)
    }
  }
  for (var i = 0; i < splittedSTR.length; i++) {
    output.push(Alpha[splittedSTR[i] - 1])
    if (output.length == splittedSTR.length) {
      console.log(output.join(''));
    }
  }
})

let Alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
process.stdin.on('data', function (data) {
  var splittedSTR = data.toString().trim().split('')
  let output = []
  for (var i = 0; i < splittedSTR.length; i++) {
    if (splittedSTR[i + 1] == 0 && splittedSTR[i + 2] != 0) {
      splittedSTR[i] = `${splittedSTR[i - 1] + splittedSTR[i]}`;
      splittedSTR.splice(i + 1, 1)
      splittedSTR.splice(i - 1, 1)
    }
  }
  console.log(splittedSTR);
  for (var i = 0; i < splittedSTR.length; i++) {
    output.push(Alpha[splittedSTR[i] - 1])
    if (output.length == splittedSTR.length) {
      console.log(output.join(''));
    }
  }
})

"use strict";

const fs = require("fs");
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

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

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

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

/*
 * Complete the 'decodeString' function below.
 *
 * The function is expected to return an INTEGER.
 * The function accepts 2D_INTEGER_ARRAY arr as parameter.
 */

function decodeString(arr) {
  // Write your code here
  const dict = [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
    "z",
  ];
  let result = [];
  for (let i = 0; i < arr.length; i++) {
    const string = arr[i].toString().split("");
    const stringLength = string.length;
    result[i] = [""];
    let j = 0;
    while (j < string.length) {
      let posPlus2 = string[j + 2];
      let posPlus3 = string[j + 3];
      if (
        j + 2 < stringLength &&
        Number(posPlus2) === 0 &&
        ((j + 3 < stringLength && Number(posPlus3) !== 0) ||
          j + 3 >= stringLength)
      ) {
        const pos = string[j] + string[j + 1];
        result[i] += dict[Number(pos - 1)];

        j += 3;
      } else {
        const pos = string[j];
        result[i] += dict[Number(pos - 1)];
        j += 1;
      }
    }
  }
}

function main() {
  const n = parseInt(readLine().trim());
  let arr = Array(n);
  for (let i = 0; i < n * 2; i++) {
    let text = readLine().replace(/\s+$/g, "").split(" ");
    if (i % 2 === 1) {
      arr[Math.floor(i / 2)] = text.map((arrTemp) => arrTemp.toString())[0];
    }
  }

  const result = decodeString(arr);
  console.log("result:", result);
}

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

let currentLine = 0;
let inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

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

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

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

function readArrayInt() {
  return inputString[currentLine++].split(" ").map(Number);
}

function readArray() {
  return inputString[currentLine++].split(" ");
}

function main() {
  const T = readInt();

  for (let i = 0; i < T; ++i) {
    const n = readInt();
    const str = readString();

    let count = 0;
    let ans = "";
    while (count < n) {
      let asd = 0;
      //   console.log(str[count]);
      if (count < n - 2 && str[count + 2] == "0") {
        asd = str[count] + str[count + 1];
        count += 2;
      } else {
        asd = str[count];
        count++;
      }

      if (asd != "0") {
        ans += String.fromCharCode(+asd + 96);
      }
    }
    console.log(ans);
  }
}

"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 alphabet = "abcdefghijklmnopqrstuvwxyz";
  let arr = [];
  let TC = readline
  for (let m = 0; m < TC; m++) {
    let res = "";
    let stringLeng = readline();
    let str = readline();
    for (let i = stringLeng - 1; i + 1; i--) {
      if (str[i] != 0) res += alphabet[str[i] - 1];
      else {
        let jam = str[i - 1] + str[i - 2];
        jam = jam.split("").reverse().join("");
        res += alphabet[jam - 1];
        i--;
        i--;
      }
    }
    res = res.split("").reverse().join("");
    arr.push(res);
  }
  arr = arr.join("\n");
  console.log(arr);
}


You have a statistic of price changes for one product represented as an array of $$$n$$$ positive integers $$$p_0, p_1, \dots, p_{n - 1}$$$, where $$$p_0$$$ is the initial price of the product and $$$p_i$$$ is how the price was increased during the $$$i$$$-th month.Using these price changes you are asked to calculate the inflation coefficients for each month as the ratio of current price increase $$$p_i$$$ to the price at the start of this month $$$(p_0 + p_1 + \dots + p_{i - 1})$$$.Your boss said you clearly that the inflation coefficients must not exceed $$$k$$$ %, so you decided to increase some values $$$p_i$$$ in such a way, that all $$$p_i$$$ remain integers and the inflation coefficients for each month don't exceed $$$k$$$ %.You know, that the bigger changes — the more obvious cheating. That's why you need to minimize the total sum of changes.What's the minimum total sum of changes you need to make all inflation coefficients not more than $$$k$$$ %?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 100$$$; $$$1 \le k \le 100$$$) — the length of array $$$p$$$ and coefficient $$$k$$$. The second line of each test case contains $$$n$$$ integers $$$p_0, p_1, \dots, p_{n - 1}$$$ ($$$1 \le p_i \le 10^9$$$) — the array $$$p$$$.

For each test case, print the minimum total sum of changes you need to make all inflation coefficients not more than $$$k$$$ %.

NoteIn the first test case, you can, for example, increase $$$p_0$$$ by $$$50$$$ and $$$p_1$$$ by $$$49$$$ and get array $$$[20150, 50, 202, 202]$$$. Then you get the next inflation coefficients:   $$$\frac{50}{20150} \le \frac{1}{100}$$$;  $$$\frac{202}{20150 + 50} \le \frac{1}{100}$$$;  $$$\frac{202}{20200 + 202} \le \frac{1}{100}$$$; In the second test case, you don't need to modify array $$$p$$$, since the inflation coefficients are already good:   $$$\frac{1}{1} \le \frac{100}{100}$$$;  $$$\frac{1}{1 + 1} \le \frac{100}{100}$$$;

var limit = parseInt(readline());
    for (var i = 0; i < limit; i++) {
        var caseConstraints = readline().split(" ");
        var caseLength = parseInt(caseConstraints[0]);
        var inflationLimit = parseInt(caseConstraints[1]);
        var caseArray = readline().split(" ");
        var caseIntArray = new Array();
        var total = 0;
        for (var j = 0; j < caseLength; j++) {
            var value = parseInt(caseArray[j]);
            if (j !== caseLength - 1) {
                total += value;
            }
            caseIntArray.push(value);
        }
        var addition = 0;
        var rightSide = inflationLimit / 100;
        for (var j = caseLength - 1; j > 0; j--) {
            if (j < caseLength - 1) {
                total -= caseIntArray[j];
            }
            var leftSide = caseIntArray[j] / total;
            if (leftSide > rightSide) {
                var newTotal = Math.ceil(caseIntArray[j] * 100 / inflationLimit);
                addition += newTotal - total;
                total = newTotal;
            }
        }
        print(addition);
    }

var t = parseInt(readline());
while(t--)
{
	var ar = readline().split(' ').map(x => +x);
	var n = ar[0];
	var k = ar[1];
	var row = readline().split(' ').map(x => +x);
	var low = 0,high = 100000000000,ans = -1;
	while(low<=high)
	{
		var mid = (low + high)/2;
		mid = Math.floor(mid);
		var sum = row[0] + mid;
		var chk = 1;
		for(var i=1;i<n;i++)
		{
			if(row[i] * 100 > sum*k)   chk = 0;
			sum += row[i];
		}
		if(chk)
		{
			ans = mid;
			high = mid - 1;
		}
		else low = mid + 1;
	}
	print(ans);
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

function main() {
    const x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var [n, k] = readline().split(' ').map(x => Number(x));
        var sum = []
        var array = readline().split(' ').map((x, i) => {
            if (i === 0) sum.push(Number(x))
            if (i > 0)sum.push(sum[i - 1] + Number(x))

            return Number(x)
        });
        var answer = 0
        // console.log(sum)
        for (var i = n - 1; i > 0; i--) {
            // console.log(array[i], sum[i - 1])
            sum[i-1] = sum[i-1] + answer
            var number = Math.ceil(array[i] * 100 / k) - sum[i - 1]
            // console.log(number)
            if (number > 0) {
                answer += number
            }
            // console.log(sum)
        }
        console.log(answer)

    })
}

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, k] = rna();
		const p = rna();

		let ans = 0;
		let psum = p[0];
		for (let i = 1; i < n; i++) {
			ans = Math.max(ans, Math.max(0, Math.ceil(100 * p[i] / k - psum)));
			psum += p[i];
		}

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

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

function main() {
    const x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var [n, k] = readline().split(' ').map(x => Number(x));
        var sum = []
        var array = readline().split(' ').map((x, i) => {
            if (i === 0) sum.push(Number(x))
            if (i > 0)sum.push(sum[i - 1] + Number(x))

            return Number(x)
        });
        var answer = 0
        for (var i = n - 1; i > 0; i--) {
            // console.log(array[i], sum[i - 1])
            var number = Math.ceil(array[i] * 100 / k) - sum[i - 1]
            // console.log(number)
            if (number > 0) answer += number
        }
        console.log(answer)

    })
}


Polycarp wants to buy exactly $$$n$$$ shovels. The shop sells packages with shovels. The store has $$$k$$$ types of packages: the package of the $$$i$$$-th type consists of exactly $$$i$$$ shovels ($$$1 \le i \le k$$$). The store has an infinite number of packages of each type.Polycarp wants to choose one type of packages and then buy several (one or more) packages of this type. What is the smallest number of packages Polycarp will have to buy to get exactly $$$n$$$ shovels?For example, if $$$n=8$$$ and $$$k=7$$$, then Polycarp will buy $$$2$$$ packages of $$$4$$$ shovels.Help Polycarp find the minimum number of packages that he needs to buy, given that he:   will buy exactly $$$n$$$ shovels in total;  the sizes of all packages he will buy are all the same and the number of shovels in each package is an integer from $$$1$$$ to $$$k$$$, inclusive.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then, $$$t$$$ test cases follow, one per line. Each test case consists of two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 10^9$$$) — the number of shovels and the number of types of packages.

Print $$$t$$$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.

NoteThe answer to the first test case was explained in the statement.In the second test case, there is only one way to buy $$$8$$$ shovels — $$$8$$$ packages of one shovel.In the third test case, you need to buy a $$$1$$$ package of $$$6$$$ shovels.

var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var one = nextIntArray();
		var N = one[0];
		var K = one[1];
		var min = 10000000000;
		if(N <= K){
			output[i] = 1;
			continue;
		}
		var list = getDivisorList(N);
		for(var j = 0; j < list.length; j++){
			if(list[j] <= K){
				min = N / list[j];
			}
		}
		output[i] = min;
	}
	myout(myconv(output,9));
}
function getDivisorList(val){
  var list = [];
  for(var i = 1; i * i <= val; i++){
    if(val % i == 0){
      list.push(i);
      if(i * i != val){
        list.push(val / i);
      }
    }
  }
  list.sort(function(a,b){ return a - b; });
  return list;
}

function getFactors(num) {
  const isEven = num % 2 === 0;
  let inc = isEven ? 1 : 2;
  let factors = [1, num];

  for (let curFactor = isEven ? 2 : 3; Math.pow(curFactor, 2) <= num; curFactor += inc) {
    if (num % curFactor !== 0) continue;
    factors.push(curFactor);
    let compliment = num / curFactor;
    if (compliment !== curFactor) factors.push(compliment);
  }

  return factors;
}

const processData = (lines) => {
  const n = +lines[0]
  for (let i=0; i<n; i++) {
    const [n, k] = lines[i+1].split(' ').map(x => +x)
    const factors = getFactors(n)
    let max = 1
    for (const f of factors) {
      if (f > max && f <= k) {
        max = f
      }
    }
    console.log(n/max)
  }
}

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

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

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var nk = readNumArray();
    var n = nk[0];
    var k = nk[1];
    if (k >= n) {
      print(1);
      continue;
    }
    var mm = Math.min(Math.ceil(Math.sqrt(n)), k);
    var maxx = 1;
    for (var j = 2; j <= mm; j++) {
      if (n % j === 0) {
        if (n / j <= k) {
          maxx = n / j;
          break;
        } else {
          maxx = j
        }

      }
    }
    print(n / maxx);
  }

}

main();

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

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var nk = readNumArray();
    var n = nk[0];
    var k = nk[1];
    if (k >= n) {
      print(1);
      continue;
    }
    var mm = Math.min(Math.ceil(Math.sqrt(n)), k);
    var maxx = 1;
    for (var j = 2; j <= mm; j++) {
      if (n % j === 0) {
        maxx = Math.max(j, n / j);
      }
    }
    print(n / maxx);
  }

}

main();

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

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var nk = readNumArray();
    var n = nk[0];
    var k = nk[1];
    if (k >= n) {
      print(1);
      continue;
    }
    var mm = Math.min(Math.ceil(Math.sqrt(n)), k);
    var maxx = 1;
    for (var j = 2; j <= mm; j++) {
      if (n % j === 0) {
        maxx = j;
      }
    }
    print(n / maxx);
  }

}

main();

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

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var nk = readNumArray();
    var n = nk[0];
    var k = nk[1];
    if (k >= n) {
      print(1);
      continue;
    }
    var mm = Math.min(Math.ceil(Math.sqrt(n)), k);
    var maxx = 1;
    for (var j = 2; j <= mm; j++) {
      if (n % j === 0) {
        maxx = n / j;
        break;
      }
    }
    print(n / maxx);
  }
}
main()

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

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var nk = readNumArray();
    var n = nk[0];
    var k = nk[1];
    if (k >= n) {
      print(1);
      continue;
    }
    var mm = Math.min(Math.ceil(Math.sqrt(n)), k);
    var maxx = 1;
    for (var j = 2; j <= mm; j++) {
      if (n % j === 0) {
        maxx = Math.max(j, n / j, maxx);
      }
    }
    print(n / maxx);
  }

}

main();

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

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var nk = readNumArray();
    var n = nk[0];
    var k = nk[1];
    print(n % k === 0 ? n / k : Math.ceil(n / k));
  }
}

 main();


There are $$$n$$$ houses in a row. They are numbered from $$$1$$$ to $$$n$$$ in order from left to right. Initially you are in the house $$$1$$$.You have to perform $$$k$$$ moves to other house. In one move you go from your current house to some other house. You can't stay where you are (i.e., in each move the new house differs from the current house). If you go from the house $$$x$$$ to the house $$$y$$$, the total distance you walked increases by $$$|x-y|$$$ units of distance, where $$$|a|$$$ is the absolute value of $$$a$$$. It is possible to visit the same house multiple times (but you can't visit the same house in sequence).Your goal is to walk exactly $$$s$$$ units of distance in total.If it is impossible, print "NO". Otherwise print "YES" and any of the ways to do that. Remember that you should do exactly $$$k$$$ moves.

The first line of the input contains three integers $$$n$$$, $$$k$$$, $$$s$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le k \le 2 \cdot 10^5$$$, $$$1 \le s \le 10^{18}$$$) — the number of houses, the number of moves and the total distance you want to walk.

If you cannot perform $$$k$$$ moves with total walking distance equal to $$$s$$$, print "NO". Otherwise print "YES" on the first line and then print exactly $$$k$$$ integers $$$h_i$$$ ($$$1 \le h_i \le n$$$) on the second line, where $$$h_i$$$ is the house you visit on the $$$i$$$-th move. For each $$$j$$$ from $$$1$$$ to $$$k-1$$$ the following condition should be satisfied: $$$h_j \ne h_{j + 1}$$$. Also $$$h_1 \ne 1$$$ should be satisfied.

function main(){
    var a = readline().split(' ');
    var n = +a[0];
    var k = +a[1];
    var s = +a[2];

    if(((n-1)*k < s) || s < k){
        print('NO');
        return;
    }

    var res = [];
    var pos = 1;
    var ss = 0;
    var sd = parseInt(s/k);
    var sf = s%k;
    var w = true;
    while(res.length != k){
        var y = sd;
        if(sf){
            y++;
            sf--;
        }
        pos = w ? pos + y : pos - y;
        w = !w;
        res.push(pos);
    }
    print('YES\n');
    res.forEach(function(v){
        print(v + ' ');
    })
}

main();

function main() {
    [n,k,s] = readInts()
    res = []
    odd = 1
    while (k>0 && s >= k + n-1){
        k--
        s-=n-1
        res.push(odd++%2? n:1)
    }
    //print(s,k, res)
    if ((k==1 && s>n-1)|| (k==0 && s>0) || s<k){
        print("NO")
        return
    }
    odd = res.length%2
    index = odd? n: 1
    increment = odd? -1: 1
    //print(increment, odd, index)
    if (k>0){
        index += (s-k+1)*increment
        if (index==1 || index==n) increment *= -1
        res.push(index)
        k--
    }
    for (i=k; i>0; i--){
        index += increment
        if (index==1 || index==n) increment *= -1
        s -= 1
        res.push(index)
    }
    print("YES")
    print(res.join(' '))

}

const TESTCASES = false
/* NodeJS Footer by @satyamcse and @shivam1420*/
var readline = require('readline');
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface({input: process.stdin, output: process.stdout});
var inp = "";
rl.on('line' , v => inp += v+"\n");
rl.on('close', () => {
    inp = inp.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
    if (TESTCASES){
        const cnt = readInt()
        for (let i = 0; i<cnt; i++){
            main()
        }
    } else {main()}
});
function sort(a, inc = true) {
    if(inc) a.sort((a, b) => a - b)
    else a.sort((a, b) => b - a)
}
var ptr = 0
function print(...x) {console.log(...x)}
function readInt() {return +inp[ptr++]}
function readLine() {return inp[ptr++]}
function readInts() {return inp[ptr++].split(' ').map(a => +a)}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function out(str) {
    console.log(str);
}
function iin() {
    return parseInt(inp())
}
function lin() {
    var array = inp().split(" ");
    var result = [];
    for (var i = 0; i < array.length; i++) {
        result.push(parseInt(array[i]));
    }
    return result;
}
function main() {
    let n, k, s, i, j;
    let i1 = lin();
    n = i1[0];
    k = i1[1];
    s = i1[2];
    if (s < k || s > (n - 1) * k) {
        out('NO')
    }
    else {
        out('YES')
        let ans = [];
        let x, y;
        x = parseInt(s / k);
        y = s % k;
        let l, r;
        l = 1
        r = x + 2
        for (i = 0; i < y; i++) {
            if (i % 2 == 0) {
                ans.push(r)
            }
            else {
                ans.push(l)
            }
        }
        if (i % 2 == 1) {
            l += 1
        }
else{
        r -= 1}
        for (i = y; i < k; i++) {
            if (i % 2 == 0) {
                ans.push(r)
            }
            else {
                ans.push(l)
            }
        }
        let ans1 = '';
        for (i = 0; i < k; i++) {
            ans1 += ans[i] + ' '
        }
        out(ans1)

    }
}

function main(){
    var a = readline().split(' ');
    var n = a[0];
    var k = a[1];
    var s = a[2];

    if((n-1)*k < s){
        print('NO');
        return;
    }

    var res = [];
    var pos = 1;
    var ss = 0;
    var sd = parseInt(s/k);
    var sf = s%k;
    var w = true;
    while(res.length != k){
        var y = sd;
        if(sf){
            y++;
            sf--;
        }
        pos = w ? pos + y : pos - y;
        w = !w;
        res.push(pos);
    }
    print('YES\n');
    res.forEach(function(v){
        print(v + ' ');
    })
}

main();

function main(){
    var a = readline().split(' ');
    var n = a[0];
    var k = a[1];
    var s = a[2];

    if((n-1)*k < s){
        print('NO');
        return;
    }

    var res = [];
    var maxStrep = n -1;
    var pos = 1;
    var ss = 0;
    var sd = parseInt(s/k);
    var sf = s%k;
    var w = true;
    while(res.length != k){
        var y = sd;
        if(sf){
            y++;
            sf--;
        }
        pos = w ? pos + y : pos - y;
        w = !w;
        res.push(pos);
    }
    print('YES\n');
    res.forEach(function(v){
        print(v + ' ');
    })
}

main();

function main(){
    var a = readline().split(' ');
    var n = a[0];
    var k = a[1];
    var s = a[2];

    if(((n-1)*k < s) || s < k){
        print('NO');
        return;
    }

    var res = [];
    var pos = 1;
    var ss = 0;
    var sd = parseInt(s/k);
    var sf = s%k;
    var w = true;
    while(res.length != k){
        var y = sd;
        if(sf){
            y++;
            sf--;
        }
        pos = w ? pos + y : pos - y;
        w = !w;
        res.push(pos);
    }
    print('YES\n');
    res.forEach(function(v){
        print(v + ' ');
    })
}

main();

function main() {
    [n,k,s] = readInts()
    res = []
    odd = 1
    while (k>0 && s >= k + n-1){
        k--
        s-=n-1
        res.push(odd++%2? n:1)
    }
    //print(s,k, res)
    if ((k==1 && s>n-1)|| (k==0 && s>0) || s<k){
        print("NO")
        return
    }
    odd = res.length%2
    index = odd? n: 1
    increment = odd? -1: 1
    //print(increment, odd, index)
    if (k>0){
        index += (s-k+1)*increment
        res.push(index)
        k--
    }
    for (i=k; i>0; i--){
        index += increment
        if (index==1 || index==n) increment *= -1
        s -= 1
        res.push(index)
    }
    print("YES")
    print(res.join(' '))

}

const TESTCASES = false
/* NodeJS Footer by @satyamcse and @shivam1420*/
var readline = require('readline');
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface({input: process.stdin, output: process.stdout});
var inp = "";
rl.on('line' , v => inp += v+"\n");
rl.on('close', () => {
    inp = inp.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
    if (TESTCASES){
        const cnt = readInt()
        for (let i = 0; i<cnt; i++){
            main()
        }
    } else {main()}
});
function sort(a, inc = true) {
    if(inc) a.sort((a, b) => a - b)
    else a.sort((a, b) => b - a)
}
var ptr = 0
function print(...x) {console.log(...x)}
function readInt() {return +inp[ptr++]}
function readLine() {return inp[ptr++]}
function readInts() {return inp[ptr++].split(' ').map(a => +a)}

function main() {
    [n,k,s] = readInts()
    res = []
    odd = 1
    while (k>0 && s >= k + n-1){
        k--
        s-=n-1
        res.push(odd++%2? n:1)
    }
    //print(s,k, res)
    if ((k==1 && s>n-1)|| (k==0 && s>0) || s<k){
        print("NO")
        return
    }
    for (i=1; i<=s/n; i++){
        res.push(i%2==0? 1: n)
    }
    odd = res.length%2
    index = odd? n: 1
    increment = odd? -1: 1
    //print(increment, odd, index)
    if (k>0){
        index += (s-k+1)*increment
        res.push(index)
        k--
    }
    for (i=k; i>0; i--){
        index += increment
        if (index==1 || index==n) increment *= -1
        s -= 1
        res.push(index)
    }
    print("YES")
    print(res.join(' '))

}

const TESTCASES = false
/* NodeJS Footer by @satyamcse and @shivam1420*/
var readline = require('readline');
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface({input: process.stdin, output: process.stdout});
var inp = "";
rl.on('line' , v => inp += v+"\n");
rl.on('close', () => {
    inp = inp.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
    if (TESTCASES){
        const cnt = readInt()
        for (let i = 0; i<cnt; i++){
            main()
        }
    } else {main()}
});
function sort(a, inc = true) {
    if(inc) a.sort((a, b) => a - b)
    else a.sort((a, b) => b - a)
}
var ptr = 0
function print(...x) {console.log(...x)}
function readInt() {return +inp[ptr++]}
function readLine() {return inp[ptr++]}
function readInts() {return inp[ptr++].split(' ').map(a => +a)}

function main() {
    [n,k,s] = readInts()
    res = []
    odd = 1
    while (k>0 && s >= k + n-1){
        k--
        s-=n-1
        res.push(odd++%2? n:1)
    }
    //print(s,k, res)
    if ((k==1 && s>n-1)|| (k==0 && s>0)){
        print("NO")
        return
    }
    for (i=1; i<=s/n; i++){
        res.push(i%2==0? 1: n)
    }
    odd = res.length%2
    index = odd? n: 1
    increment = odd? -1: 1
    //print(increment, odd, index)
    if (k>0){
        index += (s-k+1)*increment
        res.push(index)
        k--
    }
    for (i=k; i>0; i--){
        index += increment
        if (index==1 || index==n) increment *= -1
        s -= 1
        res.push(index)
    }
    print("YES")
    print(res.join(' '))

}

const TESTCASES = false
/* NodeJS Footer by @satyamcse and @shivam1420*/
var readline = require('readline');
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface({input: process.stdin, output: process.stdout});
var inp = "";
rl.on('line' , v => inp += v+"\n");
rl.on('close', () => {
    inp = inp.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
    if (TESTCASES){
        const cnt = readInt()
        for (let i = 0; i<cnt; i++){
            main()
        }
    } else {main()}
});
function sort(a, inc = true) {
    if(inc) a.sort((a, b) => a - b)
    else a.sort((a, b) => b - a)
}
var ptr = 0
function print(...x) {console.log(...x)}
function readInt() {return +inp[ptr++]}
function readLine() {return inp[ptr++]}
function readInts() {return inp[ptr++].split(' ').map(a => +a)}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function out(str) {
    console.log(str);
}
function iin() {
    return parseInt(inp())
}
function lin() {
    var array = inp().split(" ");
    var result = [];
    for (var i = 0; i < array.length; i++) {
        result.push(parseInt(array[i]));
    }
    return result;
}
function main() {
    let n, k, s, i, j;
    let i1 = lin();
    n = i1[0];
    k = i1[1];
    s = i1[2];
    if (s < k || s > (n - 1) * k) {
        out('NO')
    }
    else {
        out('YES')
        let ans = [];
        let x, y;
        x = parseInt(s / k);
        y = s % k;
        let l, r;
        l = 1
        r = x + 2
        for (i = 0; i < y; i++) {
            if (i % 2 == 0) {
                ans.push(r)
            }
            else {
                ans.push(l)
            }
        }
        if (i % 2 == 1) {
            l += 1
        }
        r -= 1
        for (i = y; i < k; i++) {
            if (i % 2 == 0) {
                ans.push(r)
            }
            else {
                ans.push(l)
            }
        }
        let ans1 = '';
        for (i = 0; i < k; i++) {
            ans1 += ans[i] + ' '
        }
        out(ans1)

    }
}


You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that:   Each element of the array should be colored in some color;  For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array;  For each $$$i$$$ from $$$1$$$ to $$$k$$$ all elements colored in the $$$i$$$-th color should be distinct. Obviously, such coloring might be impossible. In this case, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions above. If there are multiple answers, you can print any.

The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$.

If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can print any.

NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples.

function calc(n, k, a) {
  if (k > n) {
    print("NO");
    return;
  }

  var dict = {};
  a.map(elem => {
    if (dict[elem]) {
      dict[elem]++;
    } else {
      dict[elem] = 1;
    }
  });

  // count of same elem > colors
  if (Math.max(...Object.keys(dict).map(key => dict[key])) > k) {
    print("NO");
    return;
  }

  var res = a
    .map((elem, index) => {
      return {
        val: elem,
        index: index
      }
    })
    .sort((a, b) => a.val - b.val)
    .map((elem, i) => {
      return {
        val: elem.val,
        index: elem.index,
        color: i % k + 1

      }
    })
    .sort((a, b) => a.index - b.index)
    .map(elem => elem.color)

  print("YES");
  print(res.join(" "));

}

var nk = readline().split(" ");
var n = parseInt(nk[0]);
var k = parseInt(nk[1]);

var a = readline().split(" ");

calc(n, k, a);

var tmp = readline().split(' ');
var n = tmp[0];
var k = tmp[1];

var arr = readline().split(' ');
var arr2 = arr.slice();

arr2.sort( function(x, y ) {
    return x - y; // incresing
});
var mx = 0, cnt = 1;

var mp = [];
var mp2 = [];
var mp3 = [];
var ans = [];

mp[arr2[0]] = 1;
mp2[arr2[0]] = [];

for( var i=1; i<arr.length; i++ ) {
    mp[ arr2[i] ] = 1;
    mp3[ i ] = 0;

    if( arr2[i] == arr2[i-1] ) cnt++;
    else {
        mx = Math.max(mx, cnt);
        cnt = 1;
    }
}
mx = Math.max(mx, cnt);

if( mx > k ) {
    print("NO");
} else {
    print("YES");

    arr.forEach( i => {

        ans.push( mp[i] );
        mp3[ mp[i] ]++;
        mp[i]++;

    });

    var ind = 0;

    for( var i=1; i<=k; i++ ) {
        if( !mp3[i] ) {
            //write( i + ' ' + mp3[i] + '\n');
            for( var j=ind; j<n; j++ ) {
                if( mp3[ ans[j] ] > 1 ) {
                    mp3[ ans[j] ]--;
                    ans[j] = i;
                    break;
                }

            }
        }
    }
    ans.forEach( i => {
        write( i + ' ');
    });
}

var tmp = readline().split(' ');
var n = tmp[0];
var k = tmp[1];

var arr = readline().split(' ');
var arr2 = arr.slice();

arr2.sort( function(x, y ) {
    return x - y; // incresing
});
var mx = 0, cnt = 1;
var mp = {};
mp[arr2[0]] = 1;

for( var i=1; i<arr.length; i++ ) {
    mp[ arr[i] ] = 1;
    if( arr2[i] == arr2[i-1] ) cnt++;
    else {
        mx = Math.max(mx, cnt);
        cnt = 1;
    }
}
mx = Math.max(mx, cnt);

if( mx > k ) {
    print("NO");
} else {
    print("YES");

    arr.forEach( i => {
        write(mp[i] + ' ');
        mp[i]++;
    });
}

function calc(n, k, a) {
  if (k > n) {
    print("NO");
    return;
  }

  var dict = {};
  a.map(elem => {
    if (dict[elem]) {
      dict[elem]++;
    } else {
      dict[elem] = 1;
    }
  });

  // count of same elem > colors
  if (Math.max(...Object.keys(dict).map(key => dict[key])) > k) {
    print("NO");
    return;
  }

  var res = a
    .map((elem, index) => {
      return {
        val: elem,
        index: index
      }
    })
    .sort((a, b) => a.val - b.val)
    .map((elem, i) => {
      return {
        val: elem.val,
        index: elem.index,
        color: i % k + 1

      }
    })
    .sort((a, b) => a.index - b.index)
    .map(elem => elem.color)

  print("YES");
  print(res.join(" "));

}

var nk = readline().split(" ");
var n = nk[0];
var k = nk[1];

var a = readline().split(" ");

calc(n, k, a);

var tmp = readline().split(' ');
var n = tmp[0];
var k = tmp[1];

var arr = readline().split(' ');
var arr2 = arr.slice();

arr2.sort( function(x, y ) {
    return x - y; // incresing
});
var mx = 0, cnt = 1;
var mp = {};
mp[arr2[0]] = 1;

for( var i=1; i<arr.length; i++ ) {
    mp[ arr2[i] ] = 1;
    if( arr2[i] == arr2[i-1] ) cnt++;
    else {
        mx = Math.max(mx, cnt);
        cnt = 1;
    }
}
mx = Math.max(mx, cnt);

if( mx > k ) {
    print("NO");
} else {
    print("YES");

    arr.forEach( i => {
        write(mp[i] + ' ');
        mp[i]++;
    });
}


In the $$$2022$$$ year, Mike found two binary integers $$$a$$$ and $$$b$$$ of length $$$n$$$ (both of them are written only by digits $$$0$$$ and $$$1$$$) that can have leading zeroes. In order not to forget them, he wanted to construct integer $$$d$$$ in the following way:   he creates an integer $$$c$$$ as a result of bitwise summing of $$$a$$$ and $$$b$$$ without transferring carry, so $$$c$$$ may have one or more $$$2$$$-s. For example, the result of bitwise summing of $$$0110$$$ and $$$1101$$$ is $$$1211$$$ or the sum of $$$011000$$$ and $$$011000$$$ is $$$022000$$$;  after that Mike replaces equal consecutive digits in $$$c$$$ by one digit, thus getting $$$d$$$. In the cases above after this operation, $$$1211$$$ becomes $$$121$$$ and $$$022000$$$ becomes $$$020$$$ (so, $$$d$$$ won't have equal consecutive digits). Unfortunately, Mike lost integer $$$a$$$ before he could calculate $$$d$$$ himself. Now, to cheer him up, you want to find any binary integer $$$a$$$ of length $$$n$$$ such that $$$d$$$ will be maximum possible as integer.Maximum possible as integer means that $$$102 > 21$$$, $$$012 < 101$$$, $$$021 = 21$$$ and so on.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. The first line of each test case contains the integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) — the length of $$$a$$$ and $$$b$$$. The second line of each test case contains binary integer $$$b$$$ of length $$$n$$$. The integer $$$b$$$ consists only of digits $$$0$$$ and $$$1$$$. It is guaranteed that the total sum of $$$n$$$ over all $$$t$$$ test cases doesn't exceed $$$10^5$$$.

For each test case output one binary integer $$$a$$$ of length $$$n$$$. Note, that $$$a$$$ or $$$b$$$ may have leading zeroes but must have the same length $$$n$$$.

NoteIn the first test case, $$$b = 0$$$ and choosing $$$a = 1$$$ gives $$$d = 1$$$ as a result.In the second test case, $$$b = 011$$$ so:   if you choose $$$a = 000$$$, $$$c$$$ will be equal to $$$011$$$, so $$$d = 01$$$;  if you choose $$$a = 111$$$, $$$c$$$ will be equal to $$$122$$$, so $$$d = 12$$$;  if you choose $$$a = 010$$$, you'll get $$$d = 021$$$.  If you select $$$a = 110$$$, you'll get $$$d = 121$$$.  We can show that answer $$$a = 110$$$ is optimal and $$$d = 121$$$ is maximum possible.In the third test case, $$$b = 110$$$. If you choose $$$a = 100$$$, you'll get $$$d = 210$$$ and it's the maximum possible $$$d$$$.In the fourth test case, $$$b = 111000$$$. If you choose $$$a = 101101$$$, you'll get $$$d = 212101$$$ and it's maximum possible $$$d$$$.In the fifth test case, $$$b = 001011$$$. If you choose $$$a = 101110$$$, you'll get $$$d = 102121$$$ and it's maximum possible $$$d$$$.

let y = '';
process.stdin.on('data', c => y += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = y.split(EOL);
	var t = lines[0];
	var e = 0;
	for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var k = lines[i].split('').map(Number);
            var l = lines[i].split('').map(Number);
            for(j = 0; j < e; j++){
                k[j]++;
                l[j] = 1;
            }
            for(j = 1; j < e; j++){
                if(k[j] == k[j - 1]){
                    k[j]--;
                    l[j]--;
                }
            }
            var ans = '';
            for(j = 0; j < l.length; j++){
                ans += l[j];
            }
            console.log(ans);
        }
	}
});

let t = 0, input = []

require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
}).on('line', line => {
  if (t == 0)
    t = +line
  else {
    input.push(line)
    if (input.length == 2 * t)
      Main()
  }
})

function Main() {
  const b_arr = input.filter((x, i) => i % 2)
  b_arr.forEach(s => {
    const b = s.split('')
    let last = 0
    const a = b.map(x => {
      if (last == 0) {
        last = 1 + +x
        return 1
      }
      else if (last == 1) {
        if (x == '1') {
          last = 2
          return 1
        }
        else {
          last = 0
          return 0
        }
      }
      else if (last == 2) {
        if (x == '1') {
          last = 1
          return 0
        }
        else {
          last = 1
          return 1
        }
      }
    })
    console.log(a.join(''))
  })
}

let inputString = '';
let currentLine = 0;
process.stdin.on('data', (data) => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map((str) => str.trim());
	main();
});
function readLine() {
	return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
	for (var a = arguments, r = a[0], i = a.length; --i; )
		r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
	return r;
}
function inv(b) {
	for (var a = MOD, u = 0, v = 1, t; b; v = t)
		(t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
	u %= MOD;
	return u < 0 ? u + MOD : u;
}
function pow(base, n) {
	if (n === 0) return 1;
	let p = pow(base, Math.floor(n / 2));
	let res = mul(mod(p), mod(p));
	if (n % 2 === 1) res = mul(mod(res), base);
	return res;
}
function highestOneBit(i) {
	i |= i >> 1;
	i |= i >> 2;
	i |= i >> 4;
	i |= i >> 8;
	i |= i >> 16;
	return i - (i >>> 1);
}
function permutation(arr, len, store = '', permutations = []) {
	if (store.length === len) {
		permutations.push(store);
		return;
	}
	for (let i = 0; i < arr.length; i++) {
		const newArr = [...arr];
		const newChar = newArr.splice(i, 1);
		permutation(newArr, len, store.concat(newChar), permutations);
	}
	return permutations;
}
function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function main() {
	let t = +readLine();
	while (t--) {
		const len = +readLine();
		const str = readLine();
		let lastVal = null;
		let result = '';

		for (let i = 0; i < len; i++) {
			const char = str[i];
			if (char === '1') {
				if (!lastVal) {
					result += '1';
					lastVal = '2';
				} else {
					if (lastVal === '2') {
						result += '0';
						lastVal = '1';
					} else if (lastVal === '1') {
						result += '1';
						lastVal = '2';
					} else {
						result += '1';
						lastVal = '2';
					}
				}
			} else {
				if (!lastVal) {
					result += '1';
					lastVal = '1';
				} else {
					if (lastVal === '2') {
						result += '1';
						lastVal = '1';
					} else if (lastVal === '1') {
						result += '0';
						lastVal = '0';
					} else {
						result += '1';
						lastVal = '1';
					}
				}
			}
		}
		console.log(result);
	}
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

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

function main() {
    const x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var n = Number(readline());
        var b = readline().split('').map(x=>Number(x));
        var ans = [1]
        b.map((x, i) => {
            if(i===0) return
            if(ans[i-1] +b[i-1] === 2 && x===0) ans.push(1)
            if(ans[i-1] +b[i-1] === 2 && x===1) ans.push(0)
            if(ans[i-1] +b[i-1] === 1 && x===1) ans.push(1)
            if(ans[i-1] +b[i-1] === 1 && x===0) ans.push(0)
            if(ans[i-1] +b[i-1] === 0 && x===1) ans.push(1)
            if(ans[i-1] +b[i-1] === 0 && x===0) ans.push(1)
        })
         // console.log(b)
         console.log(ans.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 b = next();
		var a = new Array(N);
		var c = new Array(N);
		c[0] = (b[0] == "1") ? "2" : "1";
		for(var j = 1; j < N; j++){
			if(b[j] == "1"){
				if(c[j - 1] == "2"){
					c[j] = "1";
				}else{
					c[j] = "2";
				}
			}else{
				if(c[j - 1] == "1"){
					c[j] = "0";
				}else{
					c[j] = "1";
				}
			}
		}
		//myerr(myconv(c, 0));
		for(var j = 0; j < N; j++){
			a[j] = myconv(c[j], 1) - myconv(b[j], 1);
		}
		myout(myconv(a, 0));
	}
}

function solve(b){
    var l = 1, r=0;
    var ans = [1];

    while(l<b.length){
        if(b[l] == 1){
            if(b[l-1]==1){
                if(ans[l-1] == 1){
                    ans.push(0);
                }else{
                    ans.push(1);
                }
            }else{
                ans.push(1);
            }
        }else{
            if(b[l-1]==0){
                if(ans[l-1]== 1){
                    ans.push(0);
                }else{
                    ans.push(1);
                }
            }else{
               if(ans[l-1]==1){
                   ans.push(1);
               }else{
                   ans.push(0);
               }
            }
        }
        l++;
    }
    return ans.join('');
}

var b = [];
var n = 0;
var t = Number(readline());
for (var i = 0; i<t;i++){
    n = Number(readline());
    b = readline().split('').map((x) => (x));
    write(solve(b)+'\n');
}

"use strict"

let iter = parseInt(readline());

for(iter; iter > 0; iter--){
    let n = parseInt(readline());
    let b = readline();
    let c = String(+b[0] + 1);
    let a = "1";

    for(let i = 1; i < n; i++){
        if(+(b[i]) + 1 != c[i - 1]){
            a += 1;
            c += (+b[i] + 1);
        } else {
            a += 0;
            c += (+b[i] + 0);
        }
    }
    print(a);
}


You are given an array $$$a[0 \ldots n-1]$$$ of length $$$n$$$ which consists of non-negative integers. Note that array indices start from zero.An array is called good if the parity of each index matches the parity of the element at that index. More formally, an array is good if for all $$$i$$$ ($$$0 \le i \le n - 1$$$) the equality $$$i \bmod 2 = a[i] \bmod 2$$$ holds, where $$$x \bmod 2$$$ is the remainder of dividing $$$x$$$ by 2.For example, the arrays [$$$0, 5, 2, 1$$$] and [$$$0, 17, 0, 3$$$] are good, and the array [$$$2, 4, 6, 7$$$] is bad, because for $$$i=1$$$, the parities of $$$i$$$ and $$$a[i]$$$ are different: $$$i \bmod 2 = 1 \bmod 2 = 1$$$, but $$$a[i] \bmod 2 = 4 \bmod 2 = 0$$$.In one move, you can take any two elements of the array and swap them (these elements are not necessarily adjacent).Find the minimum number of moves in which you can make the array $$$a$$$ good, or say that this is not possible.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then $$$t$$$ test cases follow. Each test case starts with a line containing an integer $$$n$$$ ($$$1 \le n \le 40$$$) — the length of the array $$$a$$$. The next line contains $$$n$$$ integers $$$a_0, a_1, \ldots, a_{n-1}$$$ ($$$0 \le a_i \le 1000$$$) — the initial array.

For each test case, output a single integer — the minimum number of moves to make the given array $$$a$$$ good, or -1 if this is not possible.

NoteIn the first test case, in the first move, you can swap the elements with indices $$$0$$$ and $$$1$$$, and in the second move, you can swap the elements with indices $$$2$$$ and $$$3$$$.In the second test case, in the first move, you need to swap the elements with indices $$$0$$$ and $$$1$$$.In the third test case, you cannot make the array good.

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let t = parseInt(readLine());
    while(t--) {
        let expectedOdd = 0;
        let expectedEven = 1;
        let n = parseInt(readLine());
        let arr = readLine().split(" ").map((x) => {return parseInt(x)});
        if(n%2!==0) {
            let odd = (n-1)/2;
            let even = n - odd;
            expectedOdd = odd;
            expectedEven = even;
        } else {
            let odd = (n)/2;
            let even = n - odd;
            expectedEven = even;
            expectedOdd = odd;
        }
        let countOdd = 0;
        let countEven = 0;
        for(let i = 0; i < arr.length; i++) {
            if (arr[i]%2 === 0) {
                countEven++;
            } else {
                countOdd++;
            }
        }
        if(countEven !== expectedEven || countOdd !== expectedOdd) {
            console.log("-1");
        } else {
            let notInPosition = 0;
            for(let i =0; i<arr.length;i++) {
                if (i%2 !== arr[i]%2) {
                    notInPosition++;
                }
            }
            console.log(notInPosition/2)
        }
    }
}

process.stdin.setEncoding('utf8');

function solve(input, length) {
  let arr = input;

  let nOdds = 0;
  let nEvens = 0;

  for (let i = 0; i < length; i++) {
    const a = arr[i];
    if (a & 1) {
      if (1 ^ (i & 1)) {
        nEvens++;
      }
    } else {
      if (i & 1) {
        nOdds++;
      }
    }
  }

  if (nOdds != nEvens) {
    console.log(-1);
  } else {
    console.log(nOdds);
  }
}

let input = '';

process.stdin.on('data', chunk => {
  if (chunk.trim() == 'end') process.stdin.emit('end');
  else input += chunk;
});

process.stdin.on('end', () => {
  input = input.trim().split(/\s+/);
  let testCases = parseInt(input[0]);
  let offset = 1;
  for (let i = 0; i < testCases; i++) {
    let len = parseInt(input[offset]);
    solve(input.slice(offset + 1, offset + 1 + len), len);
    offset += 1 + len;
  }

  process.exit(0);
});

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 _ = +readLine();
    const nums = readLine()
      .split(" ")
      .map((n) => parseInt(n));
    console.log(solve(nums));
  }

  function solve(nums) {
    if (nums.length === 1 && nums[0] % 2 === 1) return -1;
    let evenRequirement =
      nums.length % 2 === 0 ? nums.length / 2 : Math.floor(nums.length / 2) + 1;
    let count = 0;
    let evenCount = 0;
    for (let i = 0; i < nums.length; i++) {
      let num = nums[i];
      if (num % 2 === 0) evenCount++;
      if (i % 2 === 0 && num % 2 !== 0) count++;
      else if (i % 2 !== 0 && num % 2 === 0) count++;
    }
    if (count % 2 === 0 && evenCount === evenRequirement) return count / 2;
    return -1;
  }
}

//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray();
		var count = 0;
		var odd = 0;
		var even = 0;
		for(var j = 0; j < N; j++){
			if(list[j] % 2 == 0){
				even++;
			}else{
				odd++;
			}
			if(list[j] % 2 != j % 2){
				count++;
			}
		}
		if(odd == Math.floor(N / 2) && even == Math.ceil(N / 2)){
			output[i] = count / 2;
		}else{
			output[i] = -1;
		}
	}
	myout(myconv(output,9));
}

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

let stdinInput = '';

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

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

function main(data) {
    data = data.split('\n');
    const testCases = data[0] * 2;
    let i = 1;
    while (i <= testCases) {
        const n = data[i] * 1;
        const arr = data[i + 1].split(' ');
        let obj = { '1': 0, '0': 0 };
        for (let j = 0; j < n; j += 1) {
            const mod = arr[j] % 2;
            const modI = j % 2;
            if (mod !== modI) obj[mod] = obj[mod] + 1;
        }
        console.log(obj[1] === obj[0] ? obj[1] : -1);
        i += 2;
    }
}

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

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

const reducer = (accumulator, value, index) => {
    accumulator[index % 2] += (value % 2 !== index % 2);
    return accumulator;
}

process.stdin.on('end', () => {
    const lines = input.split('\n');
    let tests = parseInt(lines.shift(), 10);
    while(tests--) {
        const n = parseInt(lines.shift(), 10);
        const arr = lines.shift().split(' ');
        const [ evenMismatch, oddMismatch ] = arr.reduce(reducer, [ 0, 0 ]);
        console.log(evenMismatch === oddMismatch ? evenMismatch : -1);
    }
});

const process = require('process')
let input = ''
process.stdin.on('data', data => input += data)
process.stdin.on('end', () => main(input))

function main(input) {
    let lines = input.trim().split('\n')
    let n = +lines[0]
    for(let i = 0; i < n; i++) {
        let arr = lines[2 + i * 2].split(' ')
        console.log(solution(arr))
    }
}

function solution(arr) {
    let N = arr.length
    let odd = even = 0

    for(let i = 0; i < N; i++) {
        let num = arr[i]
        if (num % 2 && i % 2 === 0) odd++
        if (num % 2 === 0 && i % 2) even++
    }

    if (even === odd) {
        return even
    }
    return -1
}

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

var input  = []
rl.on('line', function(line){
    input.push(line);
})

rl.on("close", ContestResponse);

function ContestResponse(){
    let index = 0;
    let nbCases= +input[index++]
    for (let i = 0; i < nbCases; i++){
      index++;
      let arr = input[index++].split(' ').map((val)=>+val);
      let hmap = {p:0, i:0}
      for (let i = 0; i < arr.length; i++){
        if (i % 2 === 0 && arr[i] % 2 !== 0)
          hmap['i']++;
        else if (i % 2 !== 0 && arr[i] % 2 === 0)
          hmap['p']++;
      }
      if (hmap['i'] !== hmap['p'])
        console.log(-1 + '');
      else
        console.log(hmap['i'] + '');
    }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

function readline() {
    return inputString[currentLine++];
}
/**
4
4
3 2 7 6
3
3 2 6
1
7
7
4 9 2 1 18 3 0

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function main() {
    let range = parseInt(readline());

    for(let r = 0;r<range;r++) {
        solve();
    }
}

function solve() {
    let n = parseInt(readline());
    let a = readline().split(" ").map(String);

    let odd = -1;
    let even = -1;

    for(let i=0;i<n;i++) {
        let lastNumber = parseInt(a[i][a[i].length - 1]);
        if(i % 2 === 0 && lastNumber % 2 !== 0) {
            odd++;
        } else if(i % 2 !== 0 && lastNumber % 2 === 0) {
            even++;
        }
    }

    if(odd === even) {
        console.log(Math.min(even, odd) + 1)
    }else {
        console.log(-1);
    }
}

var x= parseInt(readline());

while(x--){
  var odds=0, evens=0;
  var a = parseInt(readline());
  var b= readline().split(' ').map(each => parseInt(each));
  b.forEach((e,index) => {
    if(e % 2===0){
      if(index %2!==0)
        evens++;
    }else{
      if(index % 2 ===0){
        odds++;
      }
    }
  });

  if(evens === odds){
    print(evens);
  }else{
    print("-1");
  }
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = parseInt(readline());
  var arr = readline()
    .split(" ")
    .map((val) => parseInt(val));
  var even = 0;
  var odd = 0;
  for (var i = 0; i < n; i++) {
    if (i % 2 == 0 && arr[i] % 2 != 0) odd++;
    if (i % 2 != 0 && arr[i] % 2 == 0) even++;
  }
  if (odd == even) print(odd);
  else print(-1);
}

function solve() {
   var T = Number(read());
   for (var t = 0; t < T; ++t) {
      var n = Number(read());
      var counter = [0, 0];
      var a = read().split(' ');
      for (var i = 0; i < n; ++i) {
         var x = Number(a[i]) % 2;
         if (x !== (i % 2)) {
            counter[x]++;
         }
      };
      if (counter[0] !== counter[1]) {
         write(-1);
      } else {
         write(counter[0]);
      }
   }
}

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

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

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

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

t = parseInt(readline());
while (t--) {
  n = parseInt(readline());
  a = readline()
    .split(' ')
    .map((x) => parseInt(x));
  if (n % 2 == 0) {
    odd = n / 2;
  } else {
    odd = (n - 1) / 2;
  }
  count_odd = a.filter((x) => x % 2 == 1).length;
  if (count_odd != odd) {
    print("-1");
  } else {
    count_diff = a.filter((x, i) => x % 2 != i % 2).length;
    print(count_diff / 2);
  }
}

function solve(n,arr) {
    var notEven = 0, notOdd = 0;
    for (var i=0; i<n; i++) {
        if (!(i & 1) && (arr[i] & 1))
            ++notEven;
        else if ((i & 1) && !(arr[i] & 1))
            ++notOdd;
    }
    return notEven == notOdd ? (notEven == 0 ? 0 : notEven) : -1;
}
var t = Number(readline());
while (t--) {
    var n = Number(readline());
    var arr = readline().split(' ').map(Number);
    print(solve(n,arr));
}

process.stdin.setEncoding('utf8');

function solve(input, length) {
  let arr = input;

  let nOdds = 0;
  let nEvens = 0;
  console.log(input, length);

  for (let i = 0; i < length; i++) {
    const a = arr[i];
    if (a & 1) {
      if (1 ^ (i & 1)) {
        nOdds++;
      }
    } else {
      if (i & 1) {
        nEvens++;
      }
    }
  }

  if (nOdds != nEvens) {
    console.log(-1);
  } else {
    console.log(nOdds);
  }
}

let input = '';

process.stdin.on('data', chunk => {
  if (chunk.trim() == 'end') process.stdin.emit('end');
  else input += chunk;
});

process.stdin.on('end', () => {
  input = input.trim().split('\n');

  for (let i = 1; i < input.length; i += 2) {
    solve(parseInt(input[i]), input[i + 1].trim().split(' '));
  }

  process.exit(0);
});

'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++];
}
/**
4
4
3 2 7 6
3
3 2 6
1
7
7
4 9 2 1 18 3 0

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function main() {
    let range = parseInt(readline());

    for(let r = 0;r<range;r++) {
        solve();
    }
}

function solve() {
    let n = parseInt(readline());
    let a = readline().split(" ").map(String);

    let odd = -1;
    let even = -1;

    for(let i=0;i<n;i++) {
        let lastNumber = parseInt(a[i][a[i].length - 1]);
        if(i % 2 === 0 && lastNumber % 2 !== 0) {
            odd++;
        } else if(i % 2 !== 0 && lastNumber % 2 === 0) {
            even++;
        }
    }

    if(odd === -1 && even === -1) {
        console.log(0);
    } else if((odd === -1 && even !== -1) || (odd !== -1 && even == -1)) {
        console.log(-1);
    } else {
        console.log(Math.min(even, odd) + 1)
    }
}

'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++];
}
/**
4
4
3 2 7 6
3
3 2 6
1
7
7
4 9 2 1 18 3 0

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function main() {
    let range = parseInt(readline());

    for(let r = 0;r<range;r++) {
        solve();
    }
}

function solve() {
    let n = parseInt(readline());
    let a = readline().split(" ").map(Number);

    let odd = -1;
    let even = -1;

    for(let i=0;i<n;i++) {
        if(i % 2 === 0 && a[i] % 2 !== 0) {
            odd++;
        } else if(i % 2 !== 0 && a[i] % 2 === 0) {
            even++;
        }
    }

    if(odd === -1 && even === -1) {
        console.log(0);
    } else if((odd === -1 && even !== -1) || (odd !== -1 && even == -1)) {
        console.log(-1);
    } else {
        console.log(Math.min(even, odd) + 1)
    }
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = parseInt(readline());
  var arr = readline()
    .split(" ")
    .map((val) => parseInt(val));
  var diff = 0;
  for (var i = 0; i < n; i++) {
    if (i % 2 != arr[i] % 2) diff++;
  }
  if (diff % 2 == 0) print(diff / 2);
  else print(-1);
}

function solve() {
   var T = Number(read());
   for (var t = 0; t < T; ++t) {
      var n = Number(read());
      var counter = 0;
      var a = read().split(' ').map(function(x, i) {
         if (x % 2 !== i % 2) {
            counter++;
         }
      });
      if (counter % 2) {
         write(-1);
      } else {
         write(Math.round(counter / 2));
      }
   }
}

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

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

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

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

function solve() {
   var T = Number(read());
   for (var t = 0; t < T; ++t) {
      var n = Number(read());
      var counter = 0;
      var a = read().split(' ');
      for (var i = 0; i < n; ++i) {
         var x = a[i];
         if ((Number(x) % 2) !== (i % 2)) {
            counter++;
         }
      };
      if (counter % 2) {
         write(-1);
      } else {
         write(Math.round(counter / 2));
      }
   }
}

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

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

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

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