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


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

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)

    }
}


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

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


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

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

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


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

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


'use strict'
var os = require('os')
function createInput(t) {
  const n = t.stdin || process.stdin,
    e = /-?\d+/g,
    r = /-?\d+(?:\.\d+)?/g
  let o = [],
    i = 0
  return {
    init: async function () {
      const t = []
      ;(o = await new Promise(e => {
        n.on('data', n => t.push(n)),
          n.on('end', function () {
            const n = t.join('').split(os.EOL)
            e(n)
          })
      })),
        (i = 0)
    },
    dried: function () {
      return i >= o.length
    },
    readLine: u,
    readLineAsNumber: function () {
      return Number(u())
    },
    readIntegersOfLine: function () {
      const t = u().match(e)
      return null == t ? [] : t.map(t => Number(t))
    },
    readNumsOfLine: function () {
      const t = u().match(r)
      return null == t ? [] : t.map(t => Number(t))
    },
  }
  function u() {
    return o[i++]
  }
}
function createOutput(t) {
  const n = t.stdout || process.stdout,
    e = t.encoding || 'ascii',
    r = t.outputBufferThreshold || 1 << 24,
    o = r >> 1,
    i = Buffer.alloc(r)
  let u = 0
  return {
    flush: c,
    print: function (t) {
      s('string' == typeof t ? t : t.toString())
    },
    println: function (t) {
      s(('string' == typeof t ? t : t.toString()).concat('\n'))
    },
  }
  function c() {
    n.write(i.toString(e, 0, u)), (u = 0)
  }
  function s(t) {
    const s = Buffer.byteLength(t, e)
    r - u < s && (c(), s > o) ? n.write(t) : (i.write(t, u, e), (u += s))
  }
}
function createInputAndOutput(t) {
  return {
    ...createInput({ stdin: t.stdin, encoding: t.encoding }),
    ...createOutput({
      stdout: t.stdout,
      encoding: t.encoding,
      outputBufferThreshold: t.outputBufferThreshold,
    }),
  }
}
async function __main__(t, n, e = {}) {
  const r = createInputAndOutput(e)
  await Promise.all([r.init(), Promise.resolve(n && n())]),
    await t(r),
    r.flush()
}
__main__(function (t) {
  const n = new Array(1010),
    e = new Array(1010),
    r = new Array(1010),
    o = new Array(1010),
    i = new Array(1010)
  for (let c = 1; c <= 1; ++c) {
    const c = t.readLineAsNumber(),
      s = t.readIntegersOfLine(),
      f = u()
    function u() {
      if (c < 2) return 0
      e.fill(0, 0, c), r.fill(-1, 0, c)
      for (let t = 0; t < c; ++t) o[t] = s[t]
      let t = 0
      for (let e = c - 1; e >= 0; --e)
        if (1 & e) i[t++] = e
        else {
          let u = s[e]
          for (; t > 0; ) {
            const c = i[--t],
              f = o[c]
            if (u === f) {
              ;(r[e] = c), (r[c] = e), (n[c] = s[c]), (u = 0)
              break
            }
            if (u < f) {
              ;(o[c] -= u), t++, (r[e] = c), (u = 0)
              break
            }
            ;(u -= f), (r[c] = e), (n[c] = s[c])
          }
          n[e] = s[e] - u
        }
      for (let e = 0; e < t; ++e) {
        const t = i[e]
        n[t] = s[t] - o[t]
      }
      for (let t = (1 & c ? c - 2 : c - 1) - 2; t > 0; t -= 2) {
        if (-1 === r[t]) continue
        const n = r[t + 1]
        ;-1 !== n && (e[t] = r[n] === t + 1 ? e[n] + 1 : 1)
      }
      let u = 0
      for (let t = 0; t < c; t += 2) u += n[t]
      let f = 0
      for (let t = 1; t < c; t += 2) f += e[t]
      return u + f
    }
    t.println(f.toString())
  }
})

'use strict'
var os = require('os')
function createInput(t) {
  const n = t.stdin || process.stdin,
    e = /-?\d+/g,
    r = /-?\d+(?:\.\d+)?/g
  let i = [],
    o = 0
  return {
    init: async function () {
      const t = []
      ;(i = await new Promise(e => {
        n.on('data', n => t.push(n)),
          n.on('end', function () {
            const n = t.join('').split(os.EOL)
            e(n)
          })
      })),
        (o = 0)
    },
    dried: function () {
      return o >= i.length
    },
    readLine: u,
    readLineAsNumber: function () {
      return Number(u())
    },
    readIntegersOfLine: function () {
      const t = u().match(e)
      return null == t ? [] : t.map(t => Number(t))
    },
    readNumsOfLine: function () {
      const t = u().match(r)
      return null == t ? [] : t.map(t => Number(t))
    },
  }
  function u() {
    return i[o++]
  }
}
function createOutput(t) {
  const n = t.stdout || process.stdout,
    e = t.encoding || 'ascii',
    r = t.outputBufferThreshold || 1 << 24,
    i = r >> 1,
    o = Buffer.alloc(r)
  let u = 0
  return {
    flush: c,
    print: function (t) {
      s('string' == typeof t ? t : t.toString())
    },
    println: function (t) {
      s(('string' == typeof t ? t : t.toString()).concat('\n'))
    },
  }
  function c() {
    n.write(o.toString(e, 0, u)), (u = 0)
  }
  function s(t) {
    const s = Buffer.byteLength(t, e)
    r - u < s && (c(), s > i) ? n.write(t) : (o.write(t, u, e), (u += s))
  }
}
function createInputAndOutput(t) {
  return {
    ...createInput({ stdin: t.stdin, encoding: t.encoding }),
    ...createOutput({
      stdout: t.stdout,
      encoding: t.encoding,
      outputBufferThreshold: t.outputBufferThreshold,
    }),
  }
}
async function __main__(t, n, e = {}) {
  const r = createInputAndOutput(e)
  await Promise.all([r.init(), Promise.resolve(n && n())]),
    await t(r),
    r.flush()
}
__main__(function (t) {
  const n = new Array(1010),
    e = new Array(1010),
    r = new Array(1010)
  for (let o = 1; o <= 1; ++o) {
    const o = t.readLineAsNumber(),
      u = t.readIntegersOfLine()
    n.fill(0, 0, o), e.fill(0, 0, o), r.fill(-1, 0, o)
    const c = i()
    function i() {
      const t = []
      let i = 0
      for (let e = o - 1; e >= 0; --e)
        if (1 & e) t[i++] = { idx: e, remain: u[e] }
        else {
          let o = u[e]
          for (; i > 0; ) {
            const { idx: c, remain: s } = t[--i]
            if (o === s) {
              ;(r[e] = c), (r[c] = e), (n[c] = u[c]), (o = 0)
              break
            }
            if (o < s) {
              ;(t[i++] = { idx: c, remain: s - o }), (r[e] = c), (o = 0)
              break
            }
            ;(o -= s), (r[c] = e), (n[c] = u[c])
          }
          n[e] = u[e] - o
        }
      for (let e = 0; e < i; ++e) {
        const { idx: r, remain: i } = t[e]
        n[r] = u[r] - i
      }
      for (let t = (1 & o ? o - 2 : o - 1) - 2; t > 0; t -= 2) {
        if (-1 === r[t]) continue
        const n = r[t + 1]
        ;-1 !== n && (e[t] = r[n] === t + 1 ? e[n] + 1 : 1)
      }
      let c = 0
      for (let t = 0; t < o; t += 2) c += n[t]
      let s = 0
      for (let t = 1; t < o; t += 2) s += e[t]
      return c + s
    }
    t.println(c.toString())
  }
})

'use strict'
var os = require('os')
function createInput(n) {
  const t = n.stdin || process.stdin,
    e = /-?\d+/g,
    r = /-?\d+(?:\.\d+)?/g
  let i = [],
    o = 0
  return {
    init: async function () {
      const n = []
      ;(i = await new Promise(e => {
        t.on('data', t => n.push(t)),
          t.on('end', function () {
            const t = n.join('').split(os.EOL)
            e(t)
          })
      })),
        (o = 0)
    },
    dried: function () {
      return o >= i.length
    },
    readLine: u,
    readLineAsNumber: function () {
      return Number(u())
    },
    readIntegersOfLine: function () {
      const n = u().match(e)
      return null == n ? [] : n.map(n => Number(n))
    },
    readNumsOfLine: function () {
      const n = u().match(r)
      return null == n ? [] : n.map(n => Number(n))
    },
  }
  function u() {
    return i[o++]
  }
}
function createOutput(n) {
  const t = n.stdout || process.stdout,
    e = n.encoding || 'ascii',
    r = n.outputBufferThreshold || 1 << 24,
    i = r >> 1,
    o = Buffer.alloc(r)
  let u = 0
  return {
    flush: s,
    print: function (n) {
      c('string' == typeof n ? n : n.toString())
    },
    println: function (n) {
      c(('string' == typeof n ? n : n.toString()).concat('\n'))
    },
  }
  function s() {
    t.write(o.toString(e, 0, u)), (u = 0)
  }
  function c(n) {
    const c = Buffer.byteLength(n, e)
    r - u < c && (s(), c > i) ? t.write(n) : (o.write(n, u, e), (u += c))
  }
}
function createInputAndOutput(n) {
  return {
    ...createInput({ stdin: n.stdin, encoding: n.encoding }),
    ...createOutput({
      stdout: n.stdout,
      encoding: n.encoding,
      outputBufferThreshold: n.outputBufferThreshold,
    }),
  }
}
async function __main__(n, t, e = {}) {
  const r = createInputAndOutput(e)
  await Promise.all([r.init(), Promise.resolve(t && t())]),
    await n(r),
    r.flush()
}
__main__(function (n) {
  const t = new Array(1010),
    e = new Array(1010),
    r = new Array(1010)
  for (let o = 1; o <= 1; ++o) {
    const o = n.readLineAsNumber(),
      u = n.readIntegersOfLine()
    t.fill(0, 0, o), e.fill(0, 0, o), r.fill(-1, 0, o)
    const s = i()
    function i() {
      const n = []
      for (let e = o - 1; e >= 0; --e)
        if (1 & e) n.push({ idx: e, remain: u[e] })
        else {
          let i = u[e]
          for (; n.length > 0; ) {
            const { idx: o, remain: s } = n.pop()
            if (i === s) {
              ;(r[e] = o), (r[o] = e), (t[o] = u[o]), (i = 0)
              break
            }
            if (i < s) {
              n.push({ idx: o, remain: s - i }), (r[e] = o), (i = 0)
              break
            }
            ;(i -= s), (r[o] = e), (t[o] = u[o])
          }
          t[e] = u[e] - i
        }
      for (const { idx: e, remain: r } of n) t[e] = u[e] - r
      for (let n = (1 & o ? o - 2 : o - 1) - 2; n > 0; n -= 2) {
        if (-1 === r[n]) continue
        const t = r[n + 1]
        ;-1 !== t && (e[n] = r[t] === n + 1 ? e[t] + 1 : 1)
      }
      let i = 0
      for (let n = 0; n < o; n += 2) i += t[n]
      let s = 0
      for (let n = 1; n < o; n += 2) s += e[n]
      return i + s
    }
    n.println(s.toString())
  }
})

'use strict'
var os = require('os')
function createInput(t) {
  const n = t.stdin || process.stdin,
    e = /-?\d+/g,
    r = /-?\d+(?:\.\d+)?/g
  let o = [],
    i = 0
  return {
    init: async function () {
      const t = []
      ;(o = await new Promise(e => {
        n.on('data', n => t.push(n)),
          n.on('end', function () {
            const n = t.join('').split(os.EOL)
            e(n)
          })
      })),
        (i = 0)
    },
    dried: function () {
      return i >= o.length
    },
    readLine: u,
    readLineAsNumber: function () {
      return Number(u())
    },
    readIntegersOfLine: function () {
      const t = u().match(e)
      return null == t ? [] : t.map(t => Number(t))
    },
    readNumsOfLine: function () {
      const t = u().match(r)
      return null == t ? [] : t.map(t => Number(t))
    },
  }
  function u() {
    return o[i++]
  }
}
function createOutput(t) {
  const n = t.stdout || process.stdout,
    e = t.encoding || 'ascii',
    r = t.outputBufferThreshold || 1 << 24,
    o = r >> 1,
    i = Buffer.alloc(r)
  let u = 0
  return {
    flush: c,
    print: function (t) {
      s('string' == typeof t ? t : t.toString())
    },
    println: function (t) {
      s(('string' == typeof t ? t : t.toString()).concat('\n'))
    },
  }
  function c() {
    n.write(i.toString(e, 0, u)), (u = 0)
  }
  function s(t) {
    const s = Buffer.byteLength(t, e)
    r - u < s && (c(), s > o) ? n.write(t) : (i.write(t, u, e), (u += s))
  }
}
function createInputAndOutput(t) {
  return {
    ...createInput({ stdin: t.stdin, encoding: t.encoding }),
    ...createOutput({
      stdout: t.stdout,
      encoding: t.encoding,
      outputBufferThreshold: t.outputBufferThreshold,
    }),
  }
}
async function __main__(t, n, e = {}) {
  const r = createInputAndOutput(e)
  await Promise.all([r.init(), Promise.resolve(n && n())]),
    await t(r),
    r.flush()
}
__main__(function (t) {
  const n = new Array(1010),
    e = new Array(1010),
    r = new Array(1010),
    o = new Array(1010),
    i = new Array(1010)
  for (let c = 1; c <= 1; ++c) {
    const c = t.readLineAsNumber(),
      s = t.readIntegersOfLine(),
      f = u()
    function u() {
      if (c < 2) return 0
      e.fill(0, 0, c), r.fill(-1, 0, c)
      for (let t = 0; t < c; ++t) o[t] = s[t]
      let t = 0
      for (let e = 0; e < c; ++e)
        if (1 & e) {
          let u = s[e]
          for (; t > 0; ) {
            const c = i[--t],
              f = o[c]
            if (u === f) {
              ;(r[e] = c), (r[c] = e), (n[c] = s[c]), (u = 0)
              break
            }
            if (u < f) {
              ;(o[c] -= u), t++, (r[e] = c), (u = 0)
              break
            }
            ;(u -= f), (r[c] = e), (n[c] = s[c])
          }
          n[e] = s[e] - u
        } else i[t++] = e
      for (let e = 0; e < t; ++e) {
        const t = i[e]
        n[t] = s[t] - o[t]
      }
      for (let t = (1 & c ? c - 2 : c - 1) - 2; t > 0; t -= 2) {
        if (-1 === r[t]) continue
        const n = r[t + 1]
        ;-1 !== n && (e[t] = r[n] === t + 1 ? e[n] + 1 : 1)
      }
      let u = 0
      for (let t = 0; t < c; t += 2) u += n[t]
      let f = 0
      for (let t = 1; t < c; t += 2) f += e[t]
      return u + f
    }
    t.println(f.toString())
  }
})

'use strict'
var os = require('os')
function createInput(t) {
  const n = t.stdin || process.stdin,
    e = /-?\d+/g,
    r = /-?\d+(?:\.\d+)?/g
  let i = [],
    o = 0
  return {
    init: async function () {
      const t = []
      ;(i = await new Promise(e => {
        n.on('data', n => t.push(n)),
          n.on('end', function () {
            const n = t.join('').split(os.EOL)
            e(n)
          })
      })),
        (o = 0)
    },
    dried: function () {
      return o >= i.length
    },
    readLine: u,
    readLineAsNumber: function () {
      return Number(u())
    },
    readIntegersOfLine: function () {
      const t = u().match(e)
      return null == t ? [] : t.map(t => Number(t))
    },
    readNumsOfLine: function () {
      const t = u().match(r)
      return null == t ? [] : t.map(t => Number(t))
    },
  }
  function u() {
    return i[o++]
  }
}
function createOutput(t) {
  const n = t.stdout || process.stdout,
    e = t.encoding || 'ascii',
    r = t.outputBufferThreshold || 1 << 24,
    i = r >> 1,
    o = Buffer.alloc(r)
  let u = 0
  return {
    flush: s,
    print: function (t) {
      c('string' == typeof t ? t : t.toString())
    },
    println: function (t) {
      c(('string' == typeof t ? t : t.toString()).concat('\n'))
    },
  }
  function s() {
    n.write(o.toString(e, 0, u)), (u = 0)
  }
  function c(t) {
    const c = Buffer.byteLength(t, e)
    r - u < c && (s(), c > i) ? n.write(t) : (o.write(t, u, e), (u += c))
  }
}
function createInputAndOutput(t) {
  return {
    ...createInput({ stdin: t.stdin, encoding: t.encoding }),
    ...createOutput({
      stdout: t.stdout,
      encoding: t.encoding,
      outputBufferThreshold: t.outputBufferThreshold,
    }),
  }
}
async function __main__(t, n, e = {}) {
  const r = createInputAndOutput(e)
  await Promise.all([r.init(), Promise.resolve(n && n())]),
    await t(r),
    r.flush()
}
__main__(function (t) {
  const n = new Array(1010),
    e = []
  for (let i = 1; i <= 1; ++i) {
    const i = t.readLineAsNumber(),
      o = t.readIntegersOfLine(),
      u = r()
    function r() {
      let t = 0
      for (let r, u = 0; u < i; u += 2) {
        let s = o[u],
          c = o[u]
        for (r = u + 1; r < i; ++r)
          if (1 & r) {
            if (((c -= o[r]), c < s && (s = c <= 0 ? 0 : c), 0 === s)) break
          } else c += o[r]
        ;(n[u] = o[u] - s), (t += n[u]), (e[u] = 0 === s ? r : -1)
      }
      for (let t = 1 & i ? i - 2 : i - 1; t >= 0; t -= 2) {
        let e = o[t],
          r = o[t]
        for (let n = t - 1; n >= 0; --n)
          if (1 & n) r += o[n]
          else if (((r -= o[n]), r < e && (e = r <= 0 ? 0 : r), 0 === e)) break
        n[t] = o[t] - e
      }
      let r = BigInt(t)
      for (let t = 1, u = i - 1; t < u; t += 2) {
        if (n[t] !== o[t]) continue
        let u = e[t + 1],
          s = 0
        for (; -1 != u && ((s += 1), n[t] === o[t] && u + 1 !== i); )
          u = e[u + 1]
        r += BigInt(s)
      }
      return r
    }
    t.println(u.toString())
  }
})

'use strict'
var os = require('os')
function createInput(t) {
  const n = t.stdin || process.stdin,
    e = /-?\d+/g,
    r = /-?\d+(?:\.\d+)?/g
  let i = [],
    o = 0
  return {
    init: async function () {
      const t = []
      ;(i = await new Promise(e => {
        n.on('data', n => t.push(n)),
          n.on('end', function () {
            const n = t.join('').split(os.EOL)
            e(n)
          })
      })),
        (o = 0)
    },
    dried: function () {
      return o >= i.length
    },
    readLine: u,
    readLineAsNumber: function () {
      return Number(u())
    },
    readIntegersOfLine: function () {
      const t = u().match(e)
      return null == t ? [] : t.map(t => Number(t))
    },
    readNumsOfLine: function () {
      const t = u().match(r)
      return null == t ? [] : t.map(t => Number(t))
    },
  }
  function u() {
    return i[o++]
  }
}
function createOutput(t) {
  const n = t.stdout || process.stdout,
    e = t.encoding || 'ascii',
    r = t.outputBufferThreshold || 1 << 24,
    i = r >> 1,
    o = Buffer.alloc(r)
  let u = 0
  return {
    flush: s,
    print: function (t) {
      c('string' == typeof t ? t : t.toString())
    },
    println: function (t) {
      c(('string' == typeof t ? t : t.toString()).concat('\n'))
    },
  }
  function s() {
    n.write(o.toString(e, 0, u)), (u = 0)
  }
  function c(t) {
    const c = Buffer.byteLength(t, e)
    r - u < c && (s(), c > i) ? n.write(t) : (o.write(t, u, e), (u += c))
  }
}
function createInputAndOutput(t) {
  return {
    ...createInput({ stdin: t.stdin, encoding: t.encoding }),
    ...createOutput({
      stdout: t.stdout,
      encoding: t.encoding,
      outputBufferThreshold: t.outputBufferThreshold,
    }),
  }
}
async function __main__(t, n, e = {}) {
  const r = createInputAndOutput(e)
  await Promise.all([r.init(), Promise.resolve(n && n())]),
    await t(r),
    r.flush()
}
__main__(function (t) {
  const n = new Array(1010),
    e = []
  for (let i = 1; i <= 1; ++i) {
    const i = t.readLineAsNumber(),
      o = t.readIntegersOfLine(),
      u = r()
    function r() {
      let t = 0
      for (let r, u = 0; u < i; u += 2) {
        let s = o[u],
          c = o[u]
        for (r = u + 1; r < i; ++r)
          if (1 & r) {
            if (((c -= o[r]), c < s && (s = c <= 0 ? 0 : c), 0 === s)) break
          } else c += o[r]
        ;(n[u] = o[u] - s), (t += n[u]), (e[u] = 0 === s ? r : -1)
      }
      for (let t = 1 & i ? i - 2 : i - 1; t >= 0; t -= 2) {
        let e = o[t],
          r = o[t]
        for (let n = t - 1; n >= 0; --n)
          if (1 & n) r += o[n]
          else if (((r -= o[n]), r < e && (e = r <= 0 ? 0 : r), 0 === e)) break
        n[t] = o[t] - e
      }
      let r = BigInt(t)
      for (let t = 1, u = i - 1; t < u; t += 2) {
        if (n[t] !== o[t]) continue
        let u = e[t + 1],
          s = 0
        for (; -1 != u && ((s += 1), u + 1 !== i); ) u = e[u + 1]
        r += BigInt(s)
      }
      return r
    }
    t.println(u.toString())
  }
})


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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const t = parseInt(arr.shift())
  const map = {
    'a': 0,
    'b': 1,
    'c': 2
  }
  const chars = ['a', 'b', 'c']

  for(let j = 0; j < t; j++) {
    const string = arr[j] + 'a'
    const len = string.length - 1
    let s = new Array(len)

    let flag = false
    if(len == 1 && string[0] == '?') {
      s[0] = 'a'
      // console.log(s)
    }
    else if(len == 1) {
      s[0] = string[0]
    }
    else if(string[0] == string[0 + 1] && string[0] != '?') {
      flag = true
    }
    else if(string[0] == '?' && string[1] != '?') {
      s[0] = chars[(map[string[1]] + 1) % 3]
    }
    else if(string[0] == '?' && string[1] == '?') {
      s[0] = 'a'
    }
    else {
      s[0] = string[0]
    }
    for(let i = 1; i < len - 1 && !flag; i++) {
      // console.log(i, s)
      if(string[i] == string[i + 1] && string[i] != '?') {
        flag = true
        break
      }

      if(string[i] != '?') s[i] = string[i]
      else if(string[i] == '?' && string[i + 1] != '?') {
        if(s[i - 1] == string[i + 1]) {
          s[i] = chars[(map[s[i - 1]] + 1) % 3]
        }
        else {
          s[i] = chars[((map[s[i - 1]] + map[string[i + 1]]) * 2) % 3]
        }
      }
      else if(string[i] == '?' && string[i + 1] == '?' && string[i + 2] != '?') {
        if(s[i - 1] == string[i + 2]) {
          let v = map[s[i - 1]]
          s[i] = chars[(v + 1) % 3]
        }
        else {
          s[i] = string[i + 2]
        }
      }
      else {
        s[i] = chars[(map[s[i - 1]] + 1) % 3]
      }
    }

    if(!flag && len > 1) {
      let last = len - 1
      if(string[last] == s[last - 1] && string[last] != '?') {
        flag = true
      }
      else if(string[last] == '?') {
        s[last] = chars[(map[s[last - 1]] + 1) % 3]
      }
      else {
        s[last] = string[last]
      }
    }

    // console.log(s)
    if(flag) console.log(-1)
    else console.log(s.join(''))
  }
})

var print = this.print || require('lol-io').print;
var write = this.write || require('lol-io').write;
var readline = this.readline || require('lol-io').readline;

var t = Number(readline()), string, array, result = true;

function test (a) {
    result = true;

    for (k = 0; k < a.length - 1; k++) {
        if (a[k] === a[k + 1]) {
            result = false;
        }
    }

    return result;
}

for (i = 0; i < t; i++) {
    string = readline();
    array = string.split('');

    for (j = 0; j < array.length; j++) {

        if (array[j] === '?') {
            if (array[j - 1] != 'a' && array[j + 1] != 'a') {
                array[j] = 'a';
            } else if (array[j - 1] != 'b' && array[j + 1] != 'b') {
                array[j] = 'b';
            } else {
                array[j] = 'c';
            }
        }
    }

    string = array.join('');

    if (test(array)) {
        print(string);
    } else {
        print(-1);
    }
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function(input) {
  _input += input;
});

process.stdin.on("end", function() {
  processData(_input);
});

function processData(input) {
  let lines = input.split("\n");

  for (let i = 1; i < lines.length; i++) {
    let word = lines[i].split("");
    for (let j = 0; j < word.length; j++) {
      let possibilities = ["a", "b", "c"];
      if (word[j] === "?") {
        let prevChar = word[j - 1];
        let nextChar = word[j + 1];
        if (prevChar === "a") {
          let index = possibilities.indexOf("a");
          if (index != -1) {
            possibilities.splice(index, 1);
          }
        } else if (prevChar === "b") {
          let index = possibilities.indexOf("b");
          if (index != -1) {
            possibilities.splice(index, 1);
          }
        } else if (prevChar === "c") {
          let index = possibilities.indexOf("c");
          if (index != -1) {
            possibilities.splice(index, 1);
          }
        }
        if (nextChar === "a") {
          let index = possibilities.indexOf("a");
          if (index != -1) {
            possibilities.splice(index, 1);
          }
        } else if (nextChar === "b") {
          let index = possibilities.indexOf("b");
          if (index != -1) {
            possibilities.splice(index, 1);
          }
        } else if (nextChar === "c") {
          let index = possibilities.indexOf("c");
          if (index != -1) {
            possibilities.splice(index, 1);
          }
        }

        if (possibilities[0] !== undefined) {
          word[j] = possibilities[0];
        }
      }
    }
    let ans = true;
    for (let j = 0; j < word.length - 1; j++) {
      // console.log(word[i], word[i - 1], word[i], word[i + 1]);
      if (word[j] === word[j - 1] || word[j] === word[j + 1]) {
        ans = false;
        break;
      }
    }
    if (ans) {
      console.log(word.join(""));
    } else console.log(-1);
  }
}

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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const t = parseInt(arr.shift())
  const map = {
    'a': 0,
    'b': 1,
    'c': 2
  }
  const chars = ['a', 'b', 'c']

  for(let j = 0; j < t; j++) {
    const string = arr[j]
    const len = string.length
    let s = new Array(len)

    let flag = false
    if(len == 1 && string[0] == '?') {
      s[0] = 'a'
      // console.log(s)
    }
    else if(len == 1) {
      s[0] = string[0]
    }
    else if(string[0] == string[0 + 1] && string[0] != '?') {
      flag = true
    }
    else if(string[0] == '?') {
      s[0] = chars[(map[string[1]] + 1) % 3]
    }
    else {
      s[0] = string[0]
    }
    for(let i = 1; i < len - 1 && !flag; i++) {
      if(string[i] == string[i + 1] && string[i] != '?') {
        flag = true
        break
      }

      if(string[i] != '?') s[i] = string[i]
      else if(string[i] == '?' && string[i + 1] != '?') {
        if(s[i - 1] == string[i + 1]) {
          s[i] = chars[(map[s[i - 1]] + 1) % 3]
        }
        else {
          s[i] = chars[((map[s[i - 1]] + map[string[i + 1]]) * 2) % 3]
        }
      }
      else if(string[i] == '?' && string[i + 1] == '?' && string[i + 2] != '?') {
        if(string[i - 1] == string[i + 2]) {
          let v = map[s[i - 1]]
          s[i] = chars[(v + 1) % 3]
        }
        else {
          s[i] = string[i + 2]
        }
      }
      else {
        s[i] = chars[(map[s[i - 1]] + 1) % 3]
      }
    }

    if(!flag && len > 1) {
      let last = len - 1
      if(string[last] == string[last - 1] && string[last] != '?') {
        flag = true
      }
      else if(string[last] == '?') {
        s[last] = chars[(map[string[1]] + 1) % 3]
      }
      else {
        s[last] = string[last]
      }
    }

    // console.log(s)
    if(flag) console.log(-1)
    else console.log(s.join(''))
  }
})

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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const t = parseInt(arr.shift())
  const map = {
    'a': 0,
    'b': 1,
    'c': 2
  }
  const chars = ['a', 'b', 'c']

  for(let j = 0; j < t; j++) {
    const string = arr[j]
    const len = string.length
    let s = new Array(len)

    let flag = false

    if(string[0] == string[0 + 1] && string[0] != '?') {
      flag = true
    }
    else if(string[0] == '?') {
      s[0] = chars[(map[string[1]] + 1) % 3]
    }
    else {
      s[0] = string[0]
    }
    for(let i = 1; i < len - 1 && !flag; i++) {
      // console.log(i, string[i], s)
      if(string[i] == string[i + 1] && string[i] != '?') {
        flag = true
        break
      }

      if(string[i] != '?') s[i] = string[i]
      else if(string[i] == '?' && string[i + 1] != '?') {
        if(s[i - 1] == string[i + 1]) {
          s[i] = chars[(map[s[i - 1]] + 1) % 3]
        }
        else {
          s[i] = chars[((map[s[i - 1]] + map[string[i + 1]]) * 2) % 3]
        }
      }
      else if(string[i] == '?' && string[i + 1] == '?' && string[i + 2] != '?') {
        if(string[i - 1] == string[i + 2]) {
          let v = map[s[i - 1]]
          s[i] = chars[(v + 1) % 3]
        }
        else {
          s[i] = string[i + 2]
        }
      }
      else {
        s[i] = chars[(map[s[i - 1]] + 1) % 3]
      }
    }

    if(!flag) {
      let last = len - 1
      if(string[last] == string[last - 1] && string[last] != '?') {
        flag = true
      }
      else if(string[last] == '?') {
        s[last] = chars[(map[string[1]] + 1) % 3]
      }
      else {
        s[last] = string[last]
      }
    }

    if(flag) console.log(-1)
    else console.log(s.join(''))
  }
})

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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const t = parseInt(arr.shift())
  const map = {
    'a': 0,
    'b': 1,
    'c': 2
  }
  const chars = ['a', 'b', 'c']

  for(let j = 0; j < t; j++) {
    const string = arr[j]
    const len = string.length
    let s = new Array(len)

    let flag = false
    if(len == 1 && string[0] != '?') {
      s[0] = 'a'
    }
    else if(len == 1) {
      s[0] = string[0]
    }
    else if(string[0] == string[0 + 1] && string[0] != '?') {
      flag = true
    }
    else if(string[0] == '?') {
      s[0] = chars[(map[string[1]] + 1) % 3]
    }
    else {
      s[0] = string[0]
    }
    for(let i = 1; i < len - 1 && !flag; i++) {
      // console.log(i, string[i], s)
      if(string[i] == string[i + 1] && string[i] != '?') {
        flag = true
        break
      }

      if(string[i] != '?') s[i] = string[i]
      else if(string[i] == '?' && string[i + 1] != '?') {
        if(s[i - 1] == string[i + 1]) {
          s[i] = chars[(map[s[i - 1]] + 1) % 3]
        }
        else {
          s[i] = chars[((map[s[i - 1]] + map[string[i + 1]]) * 2) % 3]
        }
      }
      else if(string[i] == '?' && string[i + 1] == '?' && string[i + 2] != '?') {
        if(string[i - 1] == string[i + 2]) {
          let v = map[s[i - 1]]
          s[i] = chars[(v + 1) % 3]
        }
        else {
          s[i] = string[i + 2]
        }
      }
      else {
        s[i] = chars[(map[s[i - 1]] + 1) % 3]
      }
    }

    if(!flag) {
      let last = len - 1
      if(string[last] == string[last - 1] && string[last] != '?') {
        flag = true
      }
      else if(string[last] == '?') {
        s[last] = chars[(map[string[1]] + 1) % 3]
      }
      else {
        s[last] = string[last]
      }
    }

    if(flag) console.log(-1)
    else console.log(s.join(''))
  }
})