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

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

function main () {
	let T = rn();
	while (T--) {
		let [a, b] = rna();
		let s = rl().split('');

		const n = s.length;
		if (a + b != n ) {
			console.log(-1);
			continue;
		}

		let ok = true;
		for (let i = 0; ok && i < Math.floor(n/2); i++) {
			if (s[i] == '?')
				s[i] = s[n-i-1];
			if (s[n-i-1] == '?')
				s[n-i-1] = s[i];
			if (s[i] != s[n-i-1])
				ok = false;
		}
		if (!ok) {
			console.log(-1);
			continue;
		}

		for (const c of s) {
			a -= c == '0';
			b -= c == '1';
		}

		for (let i = 0; i < Math.floor(n/2); i++) {
			if (s[i] == '?') {
				if (a > 1) {
					s[i] = s[n-i-1] = '0';
					a -= 2;
				} else {
					s[i] = s[n-i-1] = '1';
					b -= 2;
				}

			}
		}

		if (n % 2 && s[(n-1)/2] == '?') {
			if (a > 0){
				s[(n-1)/2] = '0';
				a--;
			} else {
				s[(n-1)/2] = '1';
				b--;
			}
		}

		if (a < 0 || b < 0) ans = false;
		else ans = s;

		console.log(ans ? ans.join('') : -1);
	}
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

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

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let [a , b] = input[z++].split(' ');
        let str = input[z++].split('');
        let n = +a + +b;
        if(n % 2 === 0){
            if((a % 2 == 1) || (b % 2 == 1)){
                console.log(-1);
                continue;
            }
        }
        if(n % 2 === 1){
            if( (str[(n-1)/2]) == 0 && (a % 2 == 0)){
                console.log(-1);
                continue;
            }
            if( (str[(n-1)/2]) == 1 && (b % 2 == 0)){
                console.log(-1);
                continue;
            }
        }
        let flag = false;
        for (let i = 0; i < n; i++) {
            if(str[i] != "?" && str[n - i - 1] != "?"){
                if(str[i] != str[n - i - 1]){
                    console.log(-1);
                    flag = true;
                    break;
                }
            }
        }
        if(flag) continue
        let c = 0;
        let d = 0;
        for (let i = 0; i < n; i++) {
            if(str[i] == "?" && str[n-i-1] != "?"){
                str[i] = str[n-i-1];
            }
        }
        for (let i = 0; i < n; i++) {
            if(str[i] != "?" && str[n-i-1] == "?"){
                str[n-i-1] = str[i];
            }
        }
        for (let i = 0; i < n; i++) {
            if(str[i] == '0') c++;
            if(str[i] == '1') d++;
        }
        if(c > a || d > b){
            console.log(-1);
            continue;
        }
        let x = a - c;
        let  y = b - d;
        let p, q;
            p = Math.floor(x / 2);
            q = Math.floor(y / 2);
        for (let i = 0; i < n; i++)
        {
            if (str[i] == '?' && p > 0)
            {
                str[i] = '0';
                str[n - i - 1] = '0';
                p--;
            }
            if (str[i] == '?' && q > 0)
            {
                str[i] = '1';
                str[n - i - 1] = '1';
                q--;
            }
            if (str[i] == '?')
            {
                if (a % 2 == 1)
                {
                    str[i] = '0';
                }
                else
                {
                    str[i] = '1';
                }
            }
        }
        console.log(str.join(''));
    }
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}
function getValue() {
  return parseInt(readline());
}
let mod = BigInt(1e9 + 7);
const solve = () => {
  let t = getValue();
  while (t--) {
    let [a, b] = iInpArr();
    let str = stringArr();
    let to = a + b,
      i = 0,
      j = str.length - 1,
      flag = false;
    while (i <= j) {
      if (i === j) {
        if (str[i] === "0") a--;
        else if (str[j] === "1") b--;
      } else if (str[i] === str[j]) {
        if (str[i] === "1") b -= 2;
        else if (str[i] === "0") a -= 2;
      } else {
        if (str[i] !== "?" && str[j] !== "?") {
          flag = true;
          break;
        } else if (str[i] !== "?") {
          if (str[i] === "0") {
            a -= 2;
            str[j] = "0";
          } else {
            b -= 2;
            str[j] = "1";
          }
        } else {
          if (str[j] === "0") {
            a -= 2;
            str[i] = "0";
          } else {
            b -= 2;
            str[i] = "1";
          }
        }
      }
      i++;
      j--;
    }
    if (a < 0 || b < 0 || flag) {
      console.log(-1);
      continue;
    }
    if (a === 0 && b === 0) {
      console.log(str.join(""));
      continue;
    }
    (i = 0), (j = str.length - 1), (flag = true);
    // console.log(a, b);
    while (i <= j) {
      if (i === j) {
        if (str[i] === "?") {
          if (a > 0) str[i] = "0";
          else if (b > 0) str[i] = "1";
          else flag = false;
        }
      } else if (str[i] === str[j]) {
        if (str[i] === "?") {
          if (b >= 2) {
            str[i] = str[j] = "1";
            b -= 2;
          } else if (a >= 2) {
            str[i] = str[j] = "0";
            a -= 2;
          } else {
            flag = false;
            break;
          }
        }
      }
      i++;
      j--;
    }
    console.log(`${flag === true ? str.join("") : -1}`);
  }
};
solve();

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

var maxN = 21
var mod = 1000000007

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

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

  Array(Number(xx)).fill(1).map((t, i) => {
    // const n = parseInt(readline());
    var [x, y] = readline().split(' ').map((x, iii) => {
      return parseInt(x)
    });
    var a = readline().split('').map((x, iii) => {
      return x
    })
    var n = a.length
    for (let j = 0; j < Math.floor(n / 2); j++) {
      if (a[j] === '0' && a[n - j - 1] === '1') return console.log(-1)
      if (a[j] === '1' && a[n - j - 1] === '0') return console.log(-1)

      if (a[j] === '0' && a[n - j - 1] === '?') {
        a[n - j - 1] = '0'
        x -= 2
      } else if (a[j] === '?' && a[n - j - 1] === '0') {
        a[j] = '0'
        x -= 2
      } else if (a[j] === '1' && a[n - j - 1] === '?') {
        a[n - j - 1] = '1'
        y -= 2
      } else if (a[j] === '?' && a[n - j - 1] === '1') {
        a[j] = '1'
        y -= 2
      } else if (a[j] === '1' && a[n - j - 1] === '1') {
        y -= 2
      } else if (a[j] === '0' && a[n - j - 1] === '0') {
        x -= 2
      }
    }
    var count = 0
    for (let j = 0; j < n; j++) {
      if (a[j] === '?') count++
    }

    for (let j = 0; j < Math.floor(n / 2); j++) {
      if (a[j] === '?' && x > 1) {
        a[j] = '0'
        a[n - j - 1] = '0'
        x -= 2
        continue
      }

      if (a[j] === '?' && y > 1) {
        a[j] = '1'
        a[n - j - 1] = '1'
        y -= 2
        continue
      }
      if (a[j] === '?') return console.log(-1)
    }
    if (n % 2 === 1 && a[Math.floor(n / 2)] === '0') {
      x--
    }
    if (n % 2 === 1 && a[Math.floor(n / 2)] === '1') {
      y--
    }

    if (n % 2 === 1 && a[Math.floor(n / 2)] === '?' && x > 0) {
      a[Math.floor(n / 2)] = '0'
      x--
    }
    if (n % 2 === 1 && a[Math.floor(n / 2)] === '?' && y > 0) {
      a[Math.floor(n / 2)] = '1'
      y--
    }
    if (x !== 0 || y !== 0) return console.log(-1)
    console.log(a.join(''))
  })
}

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

//  Write your logic in `main`

const reverse = (palindrome) => palindrome.split("").reverse().join("");

const makePalindrome = (palindrome, counts) => {
  let newPalindrome = "";
  for (let i = 0; i < Math.ceil(palindrome.length / 2); i++) {
    let left = palindrome[i];
    let right = palindrome[palindrome.length - 1 - i];

    if (left !== right && left !== "?" && right !== "?") {
      // console.log("error: no match");
      return -1;
    }

    let character = left;

    if (left === "?") {
      left = right;
      character = right;
    }

    if (right === "?") {
      right = left;
      character = left;
    }

    newPalindrome += character;

    counts[left] -= 1;
    if (i !== palindrome.length - 1 - i) {
      counts[right] -= 1;
    }
  }

  if (counts["0"] < 0 || counts["1"] < 0) {
    return -1;
  }

  if (
    counts["?"] % 2 === 0 &&
    (counts["0"] % 2 !== 0 || counts["1"] % 2 !== 0)
  ) {
    // console.log("error: not even");
    return -1;
  }

  counts["?"] += counts["1"] + counts["0"];

  if (counts["?"] !== 0) {
    // console.log("error: not zero");
    return -1;
  }

  // console.log("looks good");

  // console.log("new", newPalindrome, counts);
  newPalindrome = newPalindrome
    .split("")
    .map((el) => {
      if (el === "?") {
        // console.log("map", counts);
        if (counts["0"] > 1) {
          counts["0"] -= 2;
          return "0";
        } else if (counts["1"] > 1) {
          counts["1"] -= 2;
          return "1";
        }

        // for a single question mark in the case with odd palindrome length
        if (counts["0"] > 0) {
          return "0";
        } else {
          return "1";
        }
      }
      return el;
    })
    .join("");

  return (
    newPalindrome +
    reverse(newPalindrome.slice(0, Math.floor(palindrome.length / 2)))
  );
};

const main = () => {
  const numberOfTestCases = 1 * readline();
  // console.log("number of test cases", numberOfTestCases);

  Array.from({ length: numberOfTestCases }).forEach(() => {
    const [zerosCount, onesCount] = readline()
      .split(" ")
      .map((el) => +el);

    // console.log(zerosCount, onesCount);

    const palindrome = readline();

    // console.log(palindrome);

    const counts = {
      0: zerosCount,
      1: onesCount,
      "?": 0,
    };

    console.log(makePalindrome(palindrome, counts));
  });
};

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

//  Write your logic in `main`

const reverse = (palindrome) => palindrome.split("").reverse().join("");

const makePalindrome = (palindrome, counts) => {
  let newPalindrome = "";
  for (let i = 0; i < Math.ceil(palindrome.length / 2); i++) {
    let left = palindrome[i];
    let right = palindrome[palindrome.length - 1 - i];

    if (left !== right && left !== "?" && right !== "?") {
      // console.log("error: no match");
      return -1;
    }

    let character = left;

    if (left === "?") {
      left = right;
      character = right;
    }

    if (right === "?") {
      right = left;
      character = left;
    }

    newPalindrome += character;

    counts[left] -= 1;
    if (i !== palindrome.length - 1 - i) {
      counts[right] -= 1;
    }
  }

  if (counts["0"] < 0 || counts["1"] < 0) {
    return -1;
  }

  if (counts["?"] % 2 === 0) {
    if (counts["0"] % 2 !== 0 || counts["1"] % 2 !== 0) {
      // console.log("error: not even");
      return -1;
    }
  }

  counts["?"] += counts["1"] + counts["0"];

  if (counts["?"] !== 0) {
    // console.log("error: not zero");
    return -1;
  }

  // console.log("looks good");

  // console.log("new", newPalindrome, counts);
  newPalindrome = newPalindrome
    .split("")
    .map((el) => {
      if (el === "?") {
        // console.log("map", counts);
        if (counts["0"] > 1) {
          counts["0"] -= 2;
          return "0";
        } else if (counts["1"] > 1) {
          counts["1"] -= 2;
          return "1";
        }

        // for a single question mark in the case with odd palindrome length
        if (counts["0"] > 0) {
          return "0";
        } else {
          return "1";
        }
      }
      return el;
    })
    .join("");

  return (
    newPalindrome +
    reverse(newPalindrome.slice(0, Math.floor(palindrome.length / 2)))
  );
};

const main = () => {
  const numberOfTestCases = 1 * readline();
  // console.log("number of test cases", numberOfTestCases);

  Array.from({ length: numberOfTestCases }).forEach(() => {
    const [zerosCount, onesCount] = readline()
      .split(" ")
      .map((el) => +el);

    // console.log(zerosCount, onesCount);

    const palindrome = readline();

    // console.log(palindrome);

    const counts = {
      0: zerosCount,
      1: onesCount,
      "?": 0,
    };

    console.log(makePalindrome(palindrome, counts));
  });
};

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

//  Write your logic in `main`

const reverse = (palindrome) => palindrome.split("").reverse().join("");

const isPalindrome = (palindrome, counts) => {
  let newPalindrome = "";
  for (let i = 0; i < Math.ceil(palindrome.length / 2); i++) {
    let left = palindrome[i];
    let right = palindrome[palindrome.length - 1 - i];

    if (left !== right && left !== "?" && right !== "?") {
      // console.log("error: no match");
      return -1;
    }

    let character = left;

    if (left === "?") {
      left = right;
      character = right;
    }

    if (right === "?") {
      right = left;
      character = left;
    }

    newPalindrome += character;

    counts[left] -= 1;
    if (i !== palindrome.length - 1 - i) {
      counts[right] -= 1;
    }
  }

  if (counts["0"] < 0 || counts["1"] < 0) {
    return -1;
  }

  if (counts["?"] % 2 === 0) {
    if (counts["0"] % 2 !== 0 || counts["1"] % 2 !== 0) {
      // console.log("error: not even");
      return -1;
    }
  }

  counts["?"] += counts["1"] + counts["0"];

  if (counts["?"] !== 0) {
    // console.log("error: not zero");
    return -1;
  }

  // console.log("looks good");

  // console.log("new", newPalindrome, counts);
  newPalindrome = newPalindrome
    .split("")
    .map((el) => {
      if (el === "?") {
        // console.log("map", counts);
        if (counts["0"] > 1) {
          counts["0"] -= 2;
          return "0";
        } else if (counts["1"] > 1) {
          counts["1"] -= 2;
          return "1";
        }

        if (counts["0"] > 0) {
          return "0";
        } else {
          return "1";
        }
      }
      return el;
    })
    .join("");

  return (
    newPalindrome +
    reverse(newPalindrome.slice(0, Math.floor(palindrome.length / 2)))
  );
};

const main = () => {
  const numberOfTestCases = 1 * readline();
  // console.log("number of test cases", numberOfTestCases);

  Array.from({ length: numberOfTestCases }).forEach(() => {
    const [zerosCount, onesCount] = readline()
      .split(" ")
      .map((el) => +el);

    // console.log(zerosCount, onesCount);

    let palindrome = readline();

    // console.log(palindrome);

    const counts = {
      0: zerosCount,
      1: onesCount,
      "?": 0,
    };

    console.log(isPalindrome(palindrome, counts));
  });
};

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var A = nextInt();
		var B = nextInt();
		var s = nextCharArray();
		var N = s.length;
		var isOK = true;
		for(var j = 0; j < N / 2; j++){
			if(s[j] == s[N - 1 - j]){
				if(s[j] == "0"){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						A--;
					}else{
						A -= 2;
					}
				}else if(s[j] == "1"){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						B--;
					}else{
						B -= 2;
					}
				}
			}else{
				if(s[j] == "?"){
					if(s[N - 1 - j] == "1"){
						s[j] = "1";
						B -= 2;
					}else{
						s[j] = "0";
						A -= 2;
					}
				}else if(s[N - 1 - j] == "?"){
					if(s[j] == "1"){
						s[N - 1 - j] = "1";
						B -= 2;
					}else{
						s[N - 1 - j] = "0";
						A -= 2;
					}
				}else{
					isOK = false;
				}
			}
		}
		for(var j = 0; j < N / 2; j++){
			if(s[j] == "?" && s[N - 1 - j] == "?"){
				if(A > 0){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						s[j] = "0";
						A--;
					}else if(A > 1){
						s[j] = "0";
						s[N - 1 - j] = "0";
						A -= 2;
					}
				}
			}
		}
		for(var j = 0; j < N / 2; j++){
			if(s[j] == "?" && s[N - 1 - j] == "?"){
				if(B > 0){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						s[j] = "1";
						B--;
					}else if(B > 1){
						s[j] = "1";
						s[N - 1 - j] = "1";
						B -= 2;
					}
				}else{
					isOK = false;
				}
			}

		}
		for(var j = 0; j < N / 2; j++){
			if(s[j] != s[N - 1 - j] || s[j] == "?" || s[N - 1 - j] == "?"){
				isOK = false;
			}
		}
		if(A < 0 || B < 0){
			isOK = false;
		}
		if(isOK){
			myout(myconv(s, 0));
		}else{
			myout(-1);
		}
	}
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

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

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let [a , b] = input[z++].split(' ');
        let str = input[z++].split('');
        let n = +a + +b;
        if(n % 2 === 0){
            if((a % 2 == 1) || (b % 2 == 1)){
                console.log(-1);
                continue;
            }
        }
        if(n % 2 === 1){
            if( (str[(n-1)/2]) == 0 && (a % 2 == 0)){
                console.log(-1);
                continue;
            }
            if( (str[(n-1)/2]) == 1 && (b % 2 == 0)){
                console.log(-1);
                continue;
            }
        }
        let flag = false;
        for (let i = 0; i < n; i++) {
            if(str[i] != "?" && str[n - i - 1] != "?"){
                if(str[i] != str[n - i - 1]){
                    console.log(-1);
                    flag = true;
                    break;
                }
            }
        }
        if(flag) continue
        let c = 0;
        let d = 0;
        for (let i = 0; i < n; i++) {
            if(str[i] == "?" && str[n-i-1] != "?"){
                str[i] = str[n-i-1];
            }
        }
        for (let i = 0; i < n; i++) {
            if(str[i] != "?" && str[n-i-1] == "?"){
                str[n-i-1] = str[i];
            }
        }
        for (let i = 0; i < n; i++) {
            if(str[i] == '0') c++;
            if(str[i] == '1') d++;
        }
        if(c > a || d > b){
            console.log(-1);
            continue;
        }
        let x = a - c;
        let  y = b - d;
        for (let i = 0; i < n; i++)
        {
            if (str[i] == '?' && Math.floor(x/2)> 0)
            {
                str[i] = '0';
                str[n - i - 1] = '0';
                x-=2;
            }
            if (str[i] == '?' && Math.floor(y/2)> 0)
            {
                str[i] = '1';
                str[n - i - 1] = '1';
                y-=2;
            }
            if (str[i] == '?')
            {
                if (a % 2 == 1)
                {
                    str[i] = '0';
                }
                else
                {
                    str[i] = '1';
                }
            }
        }
        console.log(str.join(''));
    }
}

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

//  Write your logic in `main`

const reverse = (palindrome) => palindrome.split("").reverse().join("");

const isPalindrome = (palindrome, counts) => {
  let newPalindrome = "";
  for (let i = 0; i < Math.ceil(palindrome.length / 2); i++) {
    let left = palindrome[i];
    let right = palindrome[palindrome.length - 1 - i];

    if (left !== right && left !== "?" && right !== "?") {
      // console.log("error: no match");
      return -1;
    }

    let character = left;

    if (left === "?") {
      left = right;
      character = right;
    }

    if (right === "?") {
      right = left;
      character = left;
    }

    newPalindrome += character;

    counts[left] -= 1;
    if (i !== palindrome.length - 1 - i) {
      counts[right] -= 1;
    }
  }

  if (counts["0"] < 0 || counts["1"] < 0) {
    return -1;
  }

  if (counts["?"] % 2 === 0) {
    if (counts["0"] % 2 !== 0 || counts["1"] % 2 !== 0) {
      // console.log("error: not even");
      return -1;
    }
  }

  counts["?"] += counts["1"] + counts["0"];

  if (counts["?"] !== 0) {
    // console.log("error: not zero");
    return -1;
  }

  // console.log("looks good");

  // console.log("new", newPalindrome, counts);
  newPalindrome = newPalindrome
    .split("")
    .map((el) => {
      if (el === "?") {
        // console.log("map", counts);
        if (counts["0"] > 0) {
          counts["0"] -= 2;
          return "0";
        } else {
          return "1";
        }
      }
      return el;
    })
    .join("");
  return (
    newPalindrome +
    reverse(newPalindrome.slice(0, Math.floor(palindrome.length / 2)))
  );
};

const main = () => {
  const numberOfTestCases = 1 * readline();
  // console.log("number of test cases", numberOfTestCases);

  Array.from({ length: numberOfTestCases }).forEach(() => {
    const [zerosCount, onesCount] = readline()
      .split(" ")
      .map((el) => +el);

    // console.log(zerosCount, onesCount);

    let palindrome = readline();

    // console.log(palindrome);

    const counts = {
      0: zerosCount,
      1: onesCount,
      "?": 0,
    };

    console.log(isPalindrome(palindrome, counts));
  });
};

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

//  Write your logic in `main`

const reverse = (palindrome) => palindrome.split("").reverse().join("");

const isPalindrome = (palindrome, counts) => {
  let newPalindrome = "";
  for (let i = 0; i < Math.ceil(palindrome.length / 2); i++) {
    let left = palindrome[i];
    let right = palindrome[palindrome.length - 1 - i];

    if (left !== right && left !== "?" && right !== "?") {
      // console.log("error: no match");
      return -1;
    }

    let character = left;

    if (left === "?") {
      left = right;
      character = right;
    }

    if (right === "?") {
      right = left;
      character = left;
    }

    newPalindrome += character;

    counts[left] -= 1;
    if (i !== palindrome.length - 1 - i) {
      counts[right] -= 1;
    }
  }

  if (counts["?"] % 2 === 0) {
    if (counts["0"] % 2 !== 0 || counts["1"] % 2 !== 0) {
      // console.log("error: not even");
      return -1;
    }
  }

  counts["?"] += counts["1"] + counts["0"];

  if (counts["?"] !== 0) {
    // console.log("error: not zero");
    return -1;
  }

  // console.log("looks good");

  // console.log("new", newPalindrome, counts);
  newPalindrome = newPalindrome
    .split("")
    .map((el) => {
      if (el === "?") {
        // console.log("map", counts);
        if (counts["0"] > 0) {
          counts["0"] -= 2;
          return "0";
        } else {
          return "1";
        }
      }
      return el;
    })
    .join("");
  return (
    newPalindrome +
    reverse(newPalindrome.slice(0, Math.floor(palindrome.length / 2)))
  );
};

const main = () => {
  const numberOfTestCases = 1 * readline();
  // console.log("number of test cases", numberOfTestCases);

  Array.from({ length: numberOfTestCases }).forEach(() => {
    const [zerosCount, onesCount] = readline()
      .split(" ")
      .map((el) => +el);

    // console.log(zerosCount, onesCount);

    let palindrome = readline();

    // console.log(palindrome);

    const counts = {
      0: zerosCount,
      1: onesCount,
      "?": 0,
    };

    console.log(isPalindrome(palindrome, counts));
  });
};

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var A = nextInt();
		var B = nextInt();
		var s = nextCharArray();
		var N = s.length;
		var isOK = true;
		for(var j = 0; j < N / 2; j++){
			if(s[j] == s[N - 1 - j]){
				if(s[j] == "0"){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						A--;
					}else{
						A -= 2;
					}
				}else if(s[j] == "1"){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						B--;
					}else{
						B -= 2;
					}
				}
			}else{
				if(s[j] == "?"){
					if(s[N - 1 - j] == "1"){
						s[j] = "1";
						B -= 2;
					}else{
						s[j] = "0";
						A -= 2;
					}
				}else if(s[N - 1 - j] == "?"){
					if(s[j] == "1"){
						s[N - 1 - j] = "1";
						B -= 2;
					}else{
						s[N - 1 - j] = "0";
						A -= 2;
					}
				}else{
					isOK = false;
				}
			}
		}
		for(var j = 0; j < N / 2; j++){
			if(s[j] == "?" && s[N - 1 - j] == "?"){
				if(A > 0){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						s[j] = "0";
						A--;
					}else if(A > 1){
						s[j] = "0";
						s[N - 1 - j] = "0";
						A -= 2;
					}
				}else if(B > 0){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						s[j] = "1";
						B--;
					}else if(B > 1){
						s[j] = "1";
						s[N - 1 - j] = "1";
						B -= 2;
					}
				}else{
					isOK = false;
				}
			}
		}
		for(var j = 0; j < N / 2; j++){
			if(s[j] != s[N - 1 - j] || s[j] == "?" || s[N - 1 - j] == "?"){
				isOK = false;
			}
		}
		if(A % 2 == 1 || B % 2 == 1 || A < 0 || B < 0){
			isOK = false;
		}
		if(isOK){
			myout(myconv(s, 0));
		}else{
			myout(-1);
		}
	}
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var A = nextInt();
		var B = nextInt();
		var s = nextCharArray();
		var N = s.length;
		var isOK = true;
		for(var j = 0; j < N / 2; j++){
			if(s[j] == s[N - 1 - j]){
				if(s[j] == "0"){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						A--;
					}else{
						A -= 2;
					}
				}else if(s[j] == "1"){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						B--;
					}else{
						B -= 2;
					}
				}
			}else{
				if(s[j] == "?"){
					if(s[N - 1 - j] == "1"){
						s[j] = "1";
						B -= 2;
					}else{
						s[j] = "0";
						A -= 2;
					}
				}else if(s[N - 1 - j] == "?"){
					if(s[j] == "1"){
						s[N - 1 - j] = "1";
						B -= 2;
					}else{
						s[N - 1 - j] = "0";
						A -= 2;
					}
				}else{
					isOK = false;
				}
			}
		}
		for(var j = 0; j < N / 2; j++){
			if(s[j] == "?" && s[N - 1 - j] == "?"){
				if(A > 0){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						s[j] = "0";
						A--;
					}else if(A > 1){
						s[j] = "0";
						s[N - 1 - j] = "0";
						A -= 2;
					}
				}else if(B > 0){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						s[j] = "1";
						B--;
					}else if(B > 1){
						s[j] = "1";
						s[N - 1 - j] = "1";
						B -= 2;
					}
				}else{
					isOK = false;
				}
			}
		}
		for(var j = 0; j < N / 2; j++){
			if(s[j] != s[N - 1 - j] || s[j] == "?"){
				isOK = false;
			}
		}
		if(A % 2 == 1 || B % 2 == 1 || A < 0 || B < 0){
			isOK = false;
		}
		if(isOK){
			myout(myconv(s, 0));
		}else{
			myout(-1);
		}
	}
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var A = nextInt();
		var B = nextInt();
		var s = nextCharArray();
		var N = s.length;
		var isOK = true;
		for(var j = 0; j < N / 2; j++){
			if(s[j] == s[N - 1 - j]){
				if(s[j] == "0"){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						A--;
					}else{
						A -= 2;
					}
				}else if(s[j] == "1"){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						B--;
					}else{
						B -= 2;
					}
				}
			}else{
				if(s[j] == "?"){
					if(s[N - 1 - j] == "1"){
						s[j] = "1";
						B -= 2;
					}else{
						s[j] = "0";
						A -= 2;
					}
				}else if(s[N - 1 - j] == "?"){
					if(s[j] == "1"){
						s[N - 1 - j] = "1";
						B -= 2;
					}else{
						s[N - 1 - j] = "0";
						A -= 2;
					}
				}else{
					isOK = false;
				}
			}
		}
		for(var j = 0; j < N / 2; j++){
			if(s[j] == "?" && s[N - 1 - j] == "?"){
				if(A > 0){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						s[j] = "0";
						A--;
					}else if(A > 1){
						s[j] = "0";
						s[N - 1 - j] = "0";
						A -= 2;
					}
				}else if(B > 0){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						s[j] = "1";
						B--;
					}else if(B > 1){
						s[j] = "1";
						s[N - 1 - j] = "1";
						B -= 2;
					}
				}else{
					isOK = false;
				}
			}
		}
		for(var j = 0; j < N / 2; j++){
			if(s[j] != s[N - 1 - j]){
				isOK = false;
			}
		}
		if(A % 2 == 1 || B % 2 == 1 || A < 0 || B < 0){
			isOK = false;
		}
		if(isOK){
			myout(myconv(s, 0));
		}else{
			myout(-1);
		}
	}
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var A = nextInt();
		var B = nextInt();
		var s = nextCharArray();
		var N = s.length;
		var isOK = true;
		for(var j = 0; j < N / 2; j++){
			if(s[j] == s[N - 1 - j]){
				if(s[j] == "0"){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						A--;
					}else{
						A -= 2;
					}
				}else if(s[j] == "1"){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						B--;
					}else{
						B -= 2;
					}
				}
			}else{
				if(s[j] == "?"){
					if(s[N - 1 - j] == "1"){
						s[j] = "1";
						B -= 2;
					}else{
						s[j] = "0";
						A -= 2;
					}
				}else if(s[N - 1 - j] == "?"){
					if(s[j] == "1"){
						s[N - 1 - j] = "1";
						B -= 2;
					}else{
						s[N - 1 - j] = "0";
						A -= 2;
					}
				}else{
					isOK = false;
				}
			}
		}
		for(var j = 0; j < N / 2; j++){
			if(s[j] == "?" && s[N - 1 - j] == "?"){
				if(A > 0){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						s[j] = "0";
						A--;
					}else if(A > 1){
						s[j] = "0";
						s[N - 1 - j] = "0";
						A -= 2;
					}
				}else if(B > 0){
					if(j == Math.ceil(N / 2) - 1 && N % 2 == 1){
						s[j] = "1";
						B--;
					}else if(B > 1){
						s[j] = "1";
						s[N - 1 - j] = "1";
						B -= 2;
					}
				}else{
					isOK = false;
				}
			}
		}

		if(A % 2 == 1 || B % 2 == 1){
			isOK = false;
		}
		if(isOK){
			myout(myconv(s, 0));
		}else{
			myout(-1);
		}
	}
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

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

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let [a , b] = input[z++].split(' ');
        let str = input[z++].split('');
        let n = +a + +b;
        if(n % 2 === 0){
            if((a % 2 == 1) || (b % 2 == 1)){
                console.log(-1);
                continue;
            }
        }
        if(n % 2 === 1){
            if( (str[(n-1)/2]) == 0 && (a % 2 == 0)){
                console.log(-1);
                continue;
            }
            if( (str[(n-1)/2]) == 1 && (b % 2 == 0)){
                console.log(-1);
                continue;
            }
        }
        let flag = false;
        for (let i = 0; i < n; i++) {
            if(str[i] != "?" && str[n - i - 1] != "?"){
                if(str[i] != str[n - i - 1]){
                    console.log(-1);
                    flag = true;
                    break;
                }
            }
        }
        if(flag) continue
        let c = 0;
        let d = 0;
        for (let i = 0; i < n; i++) {
            if(str[i] == "?" && str[n-i-1] != "?"){
                str[i] = str[n-i-1];
            }
        }
        for (let i = 0; i < n; i++) {
            if(str[i] != "?" && str[n-i-1] == "?"){
                str[n-i-1] = str[i];
            }
        }
        for (let i = 0; i < n; i++) {
            if(str[i] == '0') c++;
            if(str[i] == '1') d++;
        }
        if(c > a || d > b){
            console.log(-1);
            continue;
        }
        let x = a - c;
        let  y = b - d;
        for (let i = 0; i < n; i++)
        {
            if (str[i] == '?' && x > 0)
            {
                str[i] = '0';
                str[n - i - 1] = '0';
                x-=2;
            }
            if (str[i] == '?' && y > 0)
            {
                str[i] = '1';
                str[n - i - 1] = '1';
                y-=2;
            }
            if (str[i] == '?')
            {
                if (a % 2 == 1)
                {
                    str[i] = '0';
                }
                else
                {
                    str[i] = '1';
                }
            }
        }
        console.log(str.join(''));
    }
}

process.stdin.resume();

process.stdin.setEncoding('utf8');

var input = '';

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

function main(input) {
    input = input.split("\n");
    let z = 0;
    let testCases = +input[z++];

    while(testCases--){
        let [a , b] = input[z++].split(' ').map(Number);
        let str = input[z++].split('');
        let n = a + b;
        if(n % 2 === 0){
            if((a % 2 == 1) || (b % 2 == 1)){
                console.log(-1);
                continue;
            }
        }
        if(n % 2 === 1){
            if( (str[(n-1)/2]) == 0 && (a % 2 == 0)){
                console.log(-1);
                continue;
            }
            if( (str[(n-1)/2]) == 1 && (b % 2 == 0)){
                console.log(-1);
                continue;
            }
        }
        let flag = false;
        for (let i = 0; i < n; i++) {
            if(str[i] != "?" && str[n - i - 1] != "?"){
                if(str[i] != str[n - i - 1]){
                    console.log(-1);
                    flag = true;
                    break;
                }
            }
        }
        if(flag) continue
        let c = 0;
        let d = 0;
        for (let i = 0; i < n; i++) {
            if(str[i] == "?" && str[n-i-1] != "?"){
                str[i] = str[n-i-1];
            }
        }
        for (let i = 0; i < n; i++) {
            if(str[i] == '0') c++;
            if(str[i] == '1') d++;
        }
        if(c > a || d > b){
            console.log(-1);
            continue;
        }
        let x = a - c;
        let  y = b - d;
        let p, q;
            p = x / 2;
            q = y / 2;
        for (let i = 0; i < n; i++)
        {
            if (str[i] == '?' && p > 0)
            {
                str[i] = '0';
                str[n - i - 1] = '0';
                p--;
            }
            if (str[i] == '?' && q > 0)
            {
                str[i] = '1';
                str[n - i - 1] = '1';
                q--;
            }
            if (str[i] == '?')
            {
                if (a % 2 == 1)
                {
                    str[i] = '0';
                }
                else
                {
                    str[i] = '1';
                }
            }
        }
        console.log(str.join(''));
    }
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}
function getValue() {
  return parseInt(readline());
}
let mod = BigInt(1e9 + 7);
const solve = () => {
  let t = getValue();
  while (t--) {
    let [a, b] = iInpArr();
    let str = stringArr();
    let to = a + b,
      i = 0,
      j = str.length - 1,
      flag = true;
    while (i <= j) {
      if (i === j) {
        if (str[i] === "0") a--;
        else if (str[j] === "1") b--;
      } else if (str[i] === str[j]) {
        if (str[i] === "1") b -= 2;
        else if (str[i] === "0") a -= 2;
      }
      i++;
      j--;
    }
    if (a < 0 || b < 0) {
      console.log(-1);
      continue;
    }
    if (a === 0 && b === 0) {
      console.log(str.join(""));
      continue;
    }
    (i = 0), (j = str.length - 1);
    while (i <= j) {
      if (i === j) {
        if (str[i] === "?") {
          if (a > 0) str[i] = "0";
          else if (b > 0) str[i] = "1";
          else flag = false;
        }
      } else if (str[i] === str[j]) {
        if (str[i] === "?") {
          if (b >= 2) {
            str[i] = str[j] = "1";
            b -= 2;
          } else if (a >= 2) {
            str[i] = str[j] = "0";
            a -= 2;
          } else {
            flag = false;
            break;
          }
        }
      } else {
        if (str[i] !== "?" && str[j] !== "?") {
          flag = false;
          break;
        } else {
          let k = str[i] !== "?" ? str[i] : str[j];
          if (k === "1") {
            if (b >= 2) {
              str[i] = str[j] = "1";
              b -= 2;
            } else {
              flag = false;
              break;
            }
          } else {
            if (a >= 2) {
              str[i] = str[j] = "0";
              a -= 2;
            } else {
              flag = false;
              break;
            }
          }
        }
      }
      i++;
      j--;
    }
    console.log(`${flag === true ? str.join("") : -1}`);
  }
};
solve();

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}
function getValue() {
  return parseInt(readline());
}
let mod = BigInt(1e9 + 7);
const solve = () => {
  let t = getValue();
  while (t--) {
    let [a, b] = iInpArr();
    let str = stringArr();
    let to = a + b,
      i = 0,
      j = str.length - 1,
      flag = true;
    while (i <= j) {
      if (i === j) {
        if (str[i] === "1") {
          if (b <= 0) flag = false;
        } else if (str[j] === "0") {
          if (a <= 0) flag = false;
        } else {
          if (a > 0) str[i] = "0";
          else if (b > 0) str[i] = "1";
          else flag = false;
        }
      } else if (str[i] === str[j]) {
        if (str[i] === "?") {
          if (b >= 2) {
            str[i] = str[j] = "1";
            b -= 2;
          } else if (a >= 2) {
            str[i] = str[j] = "0";
            a -= 2;
          } else {
            flag = false;
            break;
          }
        } else {
          if (str[i] === "0" && a >= 2) a -= 2;
          else if (str[i] === "1" && b >= 2) b -= 2;
          else {
            flag = false;
            break;
          }
        }
      } else {
        if (str[i] !== "?" && str[j] !== "?") {
          flag = false;
          break;
        } else {
          let k = str[i] !== "?" ? str[i] : str[j];
          if (k === "1") {
            if (b >= 2) {
              str[i] = str[j] = "1";
              b -= 2;
            } else {
              flag = false;
              break;
            }
          } else {
            if (a >= 2) {
              str[i] = str[j] = "0";
              a -= 2;
            } else {
              flag = false;
              break;
            }
          }
        }
      }
      i++;
      j--;
    }
    console.log(`${flag === true ? str.join("") : -1}`);
  }
};
solve();

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

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

function main () {
	let t = rn();
	while (t--) {
		let [a, b] = rna();
		let s = rl();

		const n = s.length;
		const cnt = [a, b];
		let ans = Array(n).fill('?');

		let mp = new Map(
				[
				['??', '?'],
				['1?', '1'],
				['0?', '0'],
				['?0', '0'],
				['?1', '1'],
				['00', '0'],
				['11', '1'],
				['10', false],
				['01', false]
				]);

		let ok = true;
		for (let i = 0; ok && i < Math.ceil(n/2); i++) {
			let x = mp.get(s[i] + s[n-i-1]);
			if (x == '?'){
				continue;
			}
			else if (x === false) {
				ok = false;;
			}
			else {
				if (cnt[x] == 0) {
					ok = false;
				}else {
					ans[i] = ans[n-i-1] = x;
					cnt[x] -= i == n-i-1 ? 1 : 2;
				}
			}
		}

		if (!ok) {
			console.log(-1);
			continue;
		}

		for (let i = 0; ok && i < Math.ceil(n/2); i++) {
			if (ans[i] == '?') {
				const need = i == n - i - 1 ? 1 : 2;
				if (cnt[0] >= need) {
					ans[i] = ans[n - i - 1] = '0';
					cnt[0] -= need;
				}else if (cnt[1] >= need) {
					ans[i] = ans[n - i - 1] = '1';
					cnt[1] -= need;
				}else {
					ok = false;
				}
			}
		}

		if (!ok) {
			console.log(-1);
			continue;
		}

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


var input = readline();
print(main(input));

// Need gcd.

function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function modularPow(a, n, mod) {
	if (n === 1) return a % mod;
	var pow = modularPow(a, Math.floor(n / 2), mod);
	if (n % 2 === 0) {
		return (pow * pow) % mod;
	}
	return (pow * pow * a) % mod;
}

function notPrime(p) {
	// exactly not prime
	// Fermat's little theorem
	if (p === 2) return false;

	var a = 2; // choose small parameter.
	if (gcd(a, p) !== 1) return true; // not prime.
	var expr = modularPow(a, p - 1, p);
	return !(expr === 1); // Exact not prime.
}

function main(number) {
	var div = 4;
	while (div < number) {
		if (notPrime(number - div) && notPrime(div)) {
			return (number - div) + ' ' + div;
		}
		div++;
	}
}

function factorization(a){
	var da = [1];
	for(i = 2; i < a; i++){
		if( a%i == 0 ){
			da.push(i);
			a = a/i;
			i = 1;
		}
	}
	da.push(a);
	return da;
}

var n = +readline();

for(var j = 4; ; j++){
	if( factorization(j).length == 2 ){
		continue;
	}
	else if( factorization(n-j).length == 2 ){
		continue;
	}
	else{
		write(j + " " + (n-j));
		break;
	}
}

var r = +readline();
var first_comp = 0;
var sec_comp = 0;

if(r % 2 == 0){
	first_comp = r - 8;
	sec_comp = r - first_comp;
 	print(first_comp + " " + sec_comp);
}else if (r % 2 != 0){
	first_comp = r - 9;
	sec_comp = r - first_comp;
	print(first_comp + " " + sec_comp);
}

var r = +readline();

// var first_num = Math.floor((r / 3) + 1);
// var sec_num = Math.floor(r - first_num);

if(r % 2 == 0){
	var first_num = Math.floor(r - 8);
	var sec_num = Math.floor(r - first_num);
 	print(first_num + " " + sec_num);
}else if (r % 2 != 0){
	var first_num = Math.floor(r - 9);
	var sec_num = Math.floor(r - first_num);
	print(first_num + " " + sec_num);
}

var n = readline() - 0;
if (n & 1) {
        print('9 ' + (n - 9));
} else {
    var a = n / 2;
    if (a & 1) {
        print((a - 1) + ' ' + (a + 1));
    } else {
        print(a + ' ' + a);
    }
}

function readNums() {
    return readline().split(' ').map(v => v - 0);
}

;(function () {

	var simpleArray = (function (n) {

		var retArray = [], controlArray = new Array(n);

		for (var i = 2; i < n; i ++) {
			if (controlArray[i] !== false) {
				retArray.push(i);

				for (var j = i; j < n; j += i) {
					controlArray[j] = false;
				}
			}
		}

		return retArray;

	})(1e6 + 5);

	print(function (n) {

		var n1, n2;

		for (var i = 4; i < n; i++) {
			n1 = i; n2 = n - n1;

			if (simpleArray.indexOf(n1) === -1 && simpleArray.indexOf(n2) === -1) {
				break;
			}
		}

		return [n1, n2].join(' ');

	}(+readline()));

}.call(this));

var numbers = parseInt(readline());
if(numbers % 2 == 1){
    print(9, numbers - 9);
} else {
    print(4, numbers - 4);
}

var n = Number(readline());
if (n%2 === 0) {
    print(4, n-4);
}
else {
    print(9, n-9);
}

function ProblemSolver() {

    this.solveCase = function() {
        var res , i , j , a , b , c ;
        res = -1;
        c = 0 ;
        for( i = 2 ; i < this.n ; i++ ) {
            a = i ;
            b = this.n - a ;
            if( this.arr[ a ] == 0 && this.arr[ b ] == 0 ) {
                c = 1 ;
                break;
            }
        }
        if( c == 0 ) {
            print( res );
        }
        else {
            print( a + " " + b );
        }
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.brr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        //this.clearArraysPerCase() ;
    };

    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init = function() {
        var i , sz , a ;
        this.lim1 = 1000010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
        this.bmfObj = new BasicMathFunctions();
        this.primes = this.bmfObj.getPrimes( 1000000 ) ;
        sz = this.primes.length;
        for( i = 0 ; i < sz ; i++ ) {
            a = this.primes[ i ] ;
            this.arr[ a ] = 1 ;
        }
    };

    this.memsetArray1D = function( arrParam , val ) {
        var i;
        if( arrParam == null ) {
            throw new Error( "No array supplied in the parameter!" );
        }
        if( val == null ) {
            throw new Error( "No value for memset has been supplied in the parameter!" );
        }
        arrParam = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            arrParam.push( val );
        }
        return arrParam;
    };

    this.getStringLength = function( stringData ) {
        var len , lengthType;
        len = stringData.length;
        lengthType = typeof len;
        if( lengthType == "function" ) {
            len = stringData.length();
        }
        else {
            len = stringData.length;
        }
        return len;
    };

    this.init();
}

function InputReader() {
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhinoStdin = function() {
        importPackage( java.io );
        importPackage( java.lang );
        var singleLine , reader;
        reader = new BufferedReader( new InputStreamReader( System[ "in" ] ) );
        this.allLines = [];
        while( true ) {
            singleLine = reader.readLine();
            if( singleLine != null ) {
                this.allLines.push( singleLine );
            }
            else {
                break;
            }
        }
    };

    this.readAllLinesFromNodeStdin = function() {
        var fsObj , size , rawData;
        process.stdin.setEncoding( 'ascii' );
        fsObj = require( 'fs' );
        size = fsObj.fstatSync( process.stdin.fd ).size;
        rawData = fsObj.readSync( process.stdin.fd , size )[ 0 ];
        this.parseRawData( rawData );
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx , lengthType;
        len = this.allLines[ this.currrentLineNumber ].length;
        lengthType = typeof len;
        if( lengthType == "function" ) {
            len = this.allLines[ this.currrentLineNumber ].length();
        }
        if( flag == 0 ) {
            res = "";
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += String.fromCharCode( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) );
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != '\t'.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = -1;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) || this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == '\t'.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                res += String.fromCharCode( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) );
            }
            if( endIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            else {
                this.currrentCharacterIndex = endIdx;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        if( currentDirectory.charAt( 1 ) != ":" ) {
            //not local machine/windows
            outputFilePath = outputFileName;
        }
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCode = function() {
        var testCases , i , hasMoreTestCases , isLocalMachine , localContext;
        isLocalMachine = false;
        try {
            if( __dirname != null && __dirname.charAt( 1 ) == ':' ) {
                //only on windows
                isLocalMachine = true;
            }
        }
        catch( ex ) {
            isLocalMachine = false;
        }
        if( isLocalMachine == true ) {
            //local machine runs on node and relies on file i/o
            print = console.log;
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
        }
        else {
            //server machine
            try {
                var rlObj = readline;
                //server runs on javasctipt v8 distribution and has readline method on global context
                this.irObj.readAllLines();
            }
            catch( ex ) {
                try {
                    var pObj = process;
                    //server runs on node
                    print = console.log;
                    this.irObj.readAllLinesFromNodeStdin();
                }
                catch( ex ) {
                    try {
                        var ipObj = importPackage;
                        //server runs on rhino
                        this.irObj.readAllLinesFromRhinoStdin();
                    }
                    catch( ex ) {
                        throw new Error( "Unknown javasctipt distribution!" );
                    }
                }
            }
        }
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            //only works for local machine(tested)
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.runCode();
}

function BasicMathFunctions() {
    this.eps = 1e-9;

    this.getPrimes = function( n ) {
        var sq , i , j , a , bitSize;
        bitSize = 31;
        this.pre = new Array();
        this.primes = new Array();
        for( i = 0 ; i < n ; i++ ) {
            this.pre.push( 0 );
        }
        sq = Math.ceil( Math.sqrt( n * 1.0 ) + this.eps );
        for( i = 3 ; i < sq ; i += 2 ) {
            a = this.pre[ i >> 6 ] & ( 1 << ( ( i >> 1 ) & bitSize ) );
            if( a == 0 ) {
                for( j = i * i ; j <= n ; j += ( i << 1 ) ) {
                    this.pre[ j >> 6 ] |= ( 1 << ( ( j >> 1 ) & bitSize ) );
                }
            }
        }
        this.primes.push( 2 );
        for( i = 3 ; i <= n ; i += 2 ) {
            a = this.pre[ i >> 6 ] & ( 1 << ( ( i >> 1 ) & bitSize ) );
            if( a == 0 ) {
                this.primes.push( i );
            }
        }
        return this.primes;
    };

    this.isPrimeUptoSqrt = function( n ) {
        var sq , i , res;
        sq = Math.ceil( Math.sqrt( n * 1.0 ) + this.eps );
        res = true;
        for( i = 2 ; i <= sq ; i++ ) {
            if( n % i == 0 ) {
                res = false;
                break;
            }
        }
        return res;
    };

    this.factorize = function( n ) {
        var sq , i , lastPrime , cnt , res;
        if( this.primes == null || this.primes.length == 0 ) {
            throw new Error( "No primes are available for factorization!" );
        }
        lastPrime = this.primes[ this.primes.length - 1 ];
        if( lastPrime * lastPrime < n ) {
            throw new Error( "Insufficient number of primes are available for factorization!" );
        }
        res = new Array();
        if( n == 1 ) {
            return res;
        }
        sq = Math.ceil( Math.sqrt( n * 1.0 ) + this.eps );
        for( i = 0 ; this.primes[ i ] <= sq ; i++ ) {
            if( n % this.primes[ i ] == 0 ) {
                cnt = 0;
                while( n % this.primes[ i ] == 0 ) {
                    n = Math.floor( n / this.primes[ i ] );
                    cnt++;
                }
                res.push( new Array() );
                res[ res.length - 1 ].push( this.primes[ i ] );
                res[ res.length - 1 ].push( cnt );
                sq = Math.ceil( Math.sqrt( n * 1.0 ) + this.eps );
            }
        }
        if( n > 1 ) {
            res.push( new Array() );
            res[ res.length - 1 ].push( n );
            res[ res.length - 1 ].push( 1 );
        }
        return res;
    };

    this.modLongInteger = function( n , mod ) {
        var factoList , sz , i , j , cnt , res , a;
        if( n == null ) {
            throw new Error( "Need the n(first) parameter!" );
        }
        if( mod == null ) {
            throw new Error( "Need the mod(second) parameter!" );
        }
        factoList = this.factorize( n );
        sz = factoList.length;
        res = 1;
        for( i = 0 ; i < sz ; i++ ) {
            a = factoList[ i ][ 0 ];
            cnt = factoList[ i ][ 1 ];
            for( j = 0 ; j < cnt ; j++ ) {
                if( res * a > 9e15 ) {
                    throw new Error( "The multiplication of numbers have gone beyond 2^53!" );
                }
                res = ( res * a ) % mod;
            }
        }
        return res;
    };

    this.multiplyTwoLongInteger = function( n , m , mod ) {
        var factoList , sz , i , j , cnt , res , a;
        if( n == null ) {
            throw new Error( "Need the n(first) parameter!" );
        }
        if( m == null ) {
            throw new Error( "Need the m(second) parameter!" );
        }
        if( mod == null ) {
            throw new Error( "Need the mod(third) parameter!" );
        }
        factoList = this.factorize( n );
        sz = factoList.length;
        res = 1;
        for( i = 0 ; i < sz ; i++ ) {
            a = factoList[ i ][ 0 ];
            cnt = factoList[ i ][ 1 ];
            for( j = 0 ; j < cnt ; j++ ) {
                if( res * a > 9e15 ) {
                    throw new Error( "The multiplication of numbers have gone beyond 2^53!" );
                }
                res = ( res * a ) % mod;
            }
        }
        factoList = this.factorize( m );
        sz = factoList.length;
        for( i = 0 ; i < sz ; i++ ) {
            a = factoList[ i ][ 0 ];
            cnt = factoList[ i ][ 1 ];
            for( j = 0 ; j < cnt ; j++ ) {
                if( res * a > 9e15 ) {
                    throw new Error( "The multiplication of numbers have gone beyond 2^53!" );
                }
                res = ( res * a ) % mod;
            }
        }
        return res;
    };

    this.bigModLongInteger = function( a , p , mod ) {
        var res , x;
        x = a;
        res = 1;
        while( p > 0 ) {
            if( p % 2 != 0 ) {
                res = this.multiplyTwoLongInteger( res , x , mod );
            }
            x = this.multiplyTwoLongInteger( x , x , mod );
            p >>= 1;
        }
        return res;
    };
}

new CodeExecutioner();

'use strict';

const isСompositeNumber = num => {
    for (let i = 2; i < num - 1; i++) {
        if (num % i === 0) {
            return true;
        }
    }

    return false;
};

(function () {
     const n = parseInt(readline());

     for (let i = 4; i < n - 1; i++) {
        if (
          isСompositeNumber(i) &&
          isСompositeNumber(n - i)
        ) {
          write(i + ' ' + (n - i));
          return;
        }
     }
 })();

var n = readline();
var q;
for (x=4;x<n;x++){
    y = n - x;
    if (sost(x)&&sost(y)){
    print(x + " " +  y);
    break;
    }
}
function sost(a){
    for (i=2;i<=Math.sqrt(a);i++){
        if (a%i==0) {q = true; break;}
        else q = false;
    }
return q;
}

//Don't have to see. start------------------------------------------
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);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
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){
  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";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//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 N = nextInt();
  for(var i = 2; i < N; i++){
    var x = i;
    var y = N - i;
    if(!isPrime(x) && !isPrime(y)){
      myout(x + " " + y);
      return;
    }
  }
}
function isPrime(val){
  if(val == null || val <= 1 || (val != 2 && val % 2 == 0)){
    return false;
  }else if(val == 2){
    return true;
  }
  var root = Math.floor(Math.sqrt(val));
  for(var i = 3; i <= root; i += 2){
    if(val % i == 0){
      return false;
    }
  }
  return true;
}

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

let ans = (x, y) => console.log(`${x} ${y}`);
function isPrime(num) {
  if (num <= 1) return false;
  if (num % 2 == 0 && num > 2) return false;
  let s = Math.sqrt(num);
  for (let i = 3; i <= s; i++) {
    if (num % i === 0) return false;
  }
  return true;
}

rl.on('line', (d) => {
  let x = Math.floor(+d / 2);
  let y = Math.ceil(+d / 2);;

  while (isPrime(x) || isPrime(y)) {
    x--;
    y++;
  }

  ans(x, y);
});

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

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

readLine.on('close', () => {
  let nums = parseInt(input[0]);

  let left = 0, right = 0;
  if (nums % 2 === 0) { left = nums/2; right = nums/2; }
  else { left = (nums-1)/2; right = (nums+1)/2; }

  while (true) {
    if ( (left % 2 === 0 || (left % 3 === 0 && left !== 3)   || (left % 5 === 0 && left !== 5) || (left % 7 === 0 && left !== 7)) &&
        (right % 2 === 0 || (right % 3 === 0 && right !== 3) || (right % 5 === 0 && right !== 5) || (right % 7 === 0 && right !== 7)) ) {
      console.log(`${left} ${right}`);
      break;
    } else {
      right -= 1; left += 1;
    }
  }
});

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split(/[\r\n]/).filter(data => data.length > 0);
for (let i = 0; i < txt.length; i ++) {
    doit(txt[i] * 1);
}

function doit(num) {
    let max=num-4;
    let min=4;
    while (true) {
        if(composite(max)&&composite(min)){
            console.log(min,max);
            return;
        }else{
            --max;
            ++min;
        }
    }
}

function composite(num) {
    for (let i = 2; i <= num / 2; i++) {
        if (num % i === 0) return true

    }
    return false;
}

// Sample code to perform I/O:

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

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = +str.trim();
    let compositeNum = [];
    for (let i = 4; i < inputs; i++) {

        if (!checkPrime(i)) {
            let difference = inputs - i;
            if (!checkPrime(difference)) {
                compositeNum.push(i, difference);
                break;
            }
        }
    }
    return compositeNum.join(' ').toString();
}

function checkPrime(num) {
    let isPrime = true;
    for (i = 2; i <= num / 2; ++i) {
        if (num % i == 0) {
            isPrime = false;
            break;
        }
    }
    return isPrime;
}

function main() {
	var n = parseInt(readline());
	var a, b;
	if (n % 2 == 0) {
		a = 8;
		b = n - 8;
	} else {
		a = 9;
		b = n - 9;
	}
	print(a, b);
}

main();

var n = Number(readline());

if (n % 2 === 0) {
    print(8, n-8);
}
else {
    print(9, n-9);
}

var x = parseInt(readline()); // user input
//var x = 787
var a = -1, b = -1;
var siv = new Array(x + 1).fill(1)
for (var n = 2; n * n <= x; n++) {
if (siv[n]) {
for (var k = n * n; k <= x; k += n)siv[k] = 0;
}
}
for (var n = 2; n < x; n++) {
if (!siv[n] && !siv[x - n]) {
a = n;
b = x - n;
break;
}
}
print(a +' '+ b)
//console.log(a, b);

var entrada = readline();
var numero = parseInt(entrada);
var x = 4;
var y;
if(numero%2===0){
    y = numero-x;
} else {
    x = 9;
	y = numero-9;
}
print(x+' '+y);

var x = parseInt(readline());
//var x = 18
var a = -1, b = -1;
var siv = new Array(x + 1).fill(1)
for (var n = 2; n * n <= x; n++) {
if (siv[n]) {
for (var k = n * n; k <= x; k += n)siv[k] = 0;
}
}
for (var n = 2; n < x; n++) {
if (!siv[n] && !siv[x - n]) {
a = n;
b = x - n;
break;
}
}
print(a +' '+ b)
//console.log(a, b);

// Generated by CoffeeScript 1.10.0
(function() {
  var a, f, i, j, k, l, len, m, n, ref, ref1, ref2, ref3;

  n = parseInt(readline());

  a = [];

  for (i = j = 2, ref = Math.sqrt(n); 2 <= ref ? j <= ref : j >= ref; i = 2 <= ref ? ++j : --j) {
    if (!a[i]) {
      for (k = l = ref1 = 2 * i, ref2 = n, ref3 = i; ref3 > 0 ? l <= ref2 : l >= ref2; k = l += ref3) {
        a[k] = true;
      }
    }
  }

  for (i = m = 0, len = a.length; m < len; i = ++m) {
    f = a[i];
    if (i < 2) {
      continue;
    }
    if (f && a[n - i]) {
      print(i + ' ' + (n - i));
      break;
    }
  }

}).call(this);

var n = parseInt(readline());
var a = 0;
function composite(n) {
	for (var i = 2; i <= Math.ceil(Math.sqrt(n)); i++){
		if (n % i == 0) return true;
	};
	return false;
}

for (var i = Math.ceil(n / 2) - 1; i > 0; i--){
	if (composite(i) && composite(n - i)) {
		a = i;
		break;
	}

}
print (a + ' ' + (n-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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let n = parseInt(readLine());
    if (n % 2 == 0) console.log(n - 4, 4)
    else console.log(n - 9, 9)
}

var designTask = function(n)
    {
        var checkArr = [4, 6, 8, 9];
        for (var i = 0; i <= 3; i++)
        {
            if ((n - checkArr[i]) % 2 === 0) return (n - checkArr[i]) + ' ' + checkArr[i];
            else if ((n - checkArr[i]) % 3 === 0) return (n - checkArr[i]) + ' ' + checkArr[i];
        }
    }
var input = readline();
print(designTask(+input));

var sourceNumber = +readline();
var firstNumber = Math.floor(sourceNumber/2);
var secondNumber = Math.ceil(sourceNumber/2);
var isFirstNumberComposite = false;
var isSecondNumberComposite = false;

while (!isSecondNumberComposite || !isFirstNumberComposite) {
    for (var start = 2; start<=Math.ceil(Math.sqrt(firstNumber)); start++) {
        if (firstNumber%start === 0) {
            isFirstNumberComposite = true;
            // print("F" + firstNumber + "/" + start);
        }
    }
    for (var start = 2; start<=Math.ceil(Math.sqrt(secondNumber)); start++) {
        if (secondNumber%start === 0) {
            isSecondNumberComposite = true;
            // print("S" + secondNumber + "/" + start);
        }
    }

    if (!isSecondNumberComposite || !isFirstNumberComposite) {
        firstNumber--;
        secondNumber++;
        isFirstNumberComposite = false;
        isSecondNumberComposite = false;
    }
}
print(firstNumber + " " + secondNumber);

var n = parseInt(readline());

var x = (n - n % 2) / 2, y = (n + n % 2) / 2;
while ((isPrime(x) || isPrime(y))){
	x--; y++;
}
print(x + " " + y);

function isPrime(p) {
	for(var i = 2; i <= Math.sqrt(p); i++) {
		if (p % i === 0)
			return false;
	}
	return true;
}

(function () {
    var num = parseInt(readline());

    if (num % 2 == 0){
        print(8 + " " + (num - 8))
    } else {
        print(9 + " " + (num - 9))
    }

    return 0;
})();

function isComposite(n) {
    for(var i = 2; i * i <= n; ++i) {
        if(n % i == 0) {
            return true;
        }
    }
    return false;
}

var n = parseInt(readline());
for(var i = 4; i * 2 <= n; ++i) {
    if(isComposite(i) && isComposite(n - i)) {
        print(i, n - i);
        break;
    }
}

// Solution By: Problem Setter

var n = parseInt(readline());  // user input
if (n % 2 == 0) print(4, + n - 4);
else print(9, n - 9);

var number = parseInt(readline());
//var number = 91;
var found = false;
for (i = 1, j = number - 1; i < j && j > 0 && i < number; i++, j--) {
  if (isPrime(i) || i < 2 || isPrime(j) || j < 2) {
    continue;
  } else {
    found = true;
    break;
  }
}
if (found) print(i + ' ' + j);
//console.log(found ? `${i},${j}` : "Not found");
function isPrime(value) {
  for (var i = 2; i < value; i++) {
    if (value % i === 0) {
      return false;
    }
  }
  return value > 1;
}

var n = parseInt(readline());
var x = 4;
var y = 0;
if(n%2==0)
{
    y = n - x;
}
else
{
    x = 9;
	y = n - 9;
}
print(x + ' ' + y);

var n = parseInt(readline()),
			x = 4, y = 0;

		while(true)	{
			if(isCheck(x))	{
				y = n - x;
				if(isCheck(y))	break;
			}

			x++;
		}

		print(x + ' ' + y);

		function isCheck(num)	{
			if(num == 2 || num == 3)	return false;
			if(num % 2 == 0 || num % 3 == 0)	return true;
			else	return false;
		};

var n = parseInt(readline())
var x = 2, y = 0

for(;x <= n/2;x++){
    y = n - x
    if(!isPrime(y) && !isPrime(x)){
        print(x + ' ' + y)
        break
    }
}

function isPrime(x){
    for(var i = 2;i<=Math.sqrt(x);i++){
        if(x%i === 0){
            return false
        }
    }
    return true
}

var input = readline();
print(main(input));

// Need gcd.

function gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function modularPow(a, n, mod) {
	if (n === 1) return a % mod;
	var pow = modularPow(a, Math.floor(n / 2), mod);
	if (n % 2 === 0) {
		return (pow * pow) % mod;
	}
	return (pow * pow * a) % mod;
}

function notPrime(p) {
	// exactly not prime
	// Fermat's little theorem
	if (p === 2) return false;

	var a = 2; // choose small parameter.
	if (gcd(a, p) !== 1) return true; // not prime.
	var expr = modularPow(a, p - 1, p);
	console.log(expr)
	return !(expr === 1); // Exact not prime.
}

function main(number) {
	var div = 4;
	while (div < number) {
		if (notPrime(number - div) && notPrime(div)) {
			return number + ' ' + div;
		}
	}
}

function primToN(n){
	var answer = [2];

	for(j = 3; j <= n; j++){
		if( answer.every(function(number){return (j%number != 0) ? true : false}) ){
			answer.push(j);
		}
	}
	j = undefined, number = undefined;
	return answer;
}

var n = +readline(), primes = primToN( (n < 100) ? n : 100 );

for(i = 4; ;i++){
	if( primes.some(function(number){return (number == i) ? true : false}) ){
		continue;
	}
	else if( primes.some(function(number){return (number == (n-i)) ? true : false}) ){
		continue;
	}
	else{
		write(i + " " + (n-i));
		break;
	}
}

var r = +readline();

if(r % 2 == 0){
	print(r / 2 + " " + r / 2);
}else if (r % 2 != 0){
	var first_num = Math.floor((r / 3) + 1);
	var sec_num = Math.floor(r - first_num);
	print(first_num + " " + sec_num);
}

var r = +readline();

if(r % 2 == 0){
	var odd = r - 1;
	var first_num = Math.floor((odd / 3) + 1);
	var sec_num = Math.floor(r - first_num);
 	print(first_num + " " + sec_num);
}else if (r % 2 != 0){
	var first_num = Math.floor((r / 3) + 1);
	var sec_num = Math.floor(r - first_num);
	print(first_num + " " + sec_num);
}

var r = +readline();

if(r % 2 == 0){
	var first_num = Math.floor(r - 4);
	var sec_num = Math.floor(r - first_num);
 	print(sec_num + " " + first_num);
}else if (r % 2 != 0){
	var first_num = Math.floor((r / 3) + 1);
	var sec_num = Math.floor(r - first_num);
	print(first_num + " " + sec_num);
}

var r = +readline();

if(r % 2 == 0){
	var odd = r - 1;
	var first_num = Math.floor((odd / 3) + 1);
	var sec_num = Math.floor(odd - first_num);
 	print(first_num + " " + sec_num);
}else if (r % 2 != 0){
	var first_num = Math.floor((r / 3) + 1);
	var sec_num = Math.floor(r - first_num);
	print(first_num + " " + sec_num);
}

var numbers = parseInt(readline());
if(numbers % 2 == 1){
    print(9, numbers - 9);
} else {
    var half = numbers / 2;
    print(half, half);
}

var numbers = parseInt(readline());
if(numbers % 2 == 1){
    print(9, numbers - 9);
} else {
    var half = numbers / 2;
    print(4, half - 4);
}

var n = Number(readline());
print(4, n-4);

var n = readline();
if(n%2==0)
print(n/2, n/2)
for (var i=1; i<10; i++){
  var c = n-(0+i);
  var b = n-c;
  if (b>2&&b%2==0)
  {
	print(c,b);
  break;
  }
}

var n = readline();
var c = n-6;
n%2==0? print(n/2, n/2):print(6, c)

var n = readline();
var c = n-3;
n%2==0? print(n/2, n/2):print(3, c)

var n = readline();
if(n%2==0)
print(n/2, n/2)
else{
for (var i=1; i<10; i++){
  var c = n-(0+i);
  var b = n-c;
  if (b>2&&b%2==0)
  {
	print(c,b);
  break;
  }
}
}

var entrada = readline();
var numero = parseInt(entrada);
var num = 0;
if(numero%2===0){
    num = numero-8;
    print('8 '+num);
} else {
	y = numero-9;
    print('9 '+num);
}

var entrada = readline();
var numero = parseInt(entrada);
var x = 4;
var y;
if(numero%2===0){
    y = numero-x;
} else {
    x = 9;
	y = numero-9;
}
print(x+', '+y);

var n = parseInt(readline());
var a = 0;
function composite(n) {
	for (var i = 2; i <= Math.ceil(Math.sqrt(n)); i++){
		if (n % i == 0) return true;
	};
	return false;
}

for (var i = 1; i < Math.ceil(n / 2); i++){
	if (composite(i) && composite(n - i)) {
		a = i;
		break;
	}

}
print (a + ' ' + (n-a));

var n = parseInt(readline());

if (n % 2 === 0) {
	print (n / 2 + " " + n / 2);
}
else {
	var x = (n - 1) / 2, y = x + 1;
	while ((isPrime(x) || isPrime(y))){
		x--; y++;
	}
	print(x + " " + y);
}

function isPrime(p) {
	for(var i = 2; i <= Math.sqrt(p); i++) {
		if (p % i === 0)
			return false;
	}
	return true;
}

(function () {
    var n = parseInt(readline());

    var names = ["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"];

    var r = 1;
    while (r * 5 < n)
    {
        n -= r * 5;
        r *= 2;
    }

    print(names[Math.floor((n - 1) / r)]);

    return 0;
})();

function isComposite(n) {
    for(var i = 2; i * i < n; ++i) {
        if(n % i == 0) {
            return true;
        }
    }
    return false;
}

var n = parseInt(readline());
for(var i = 4; i * 2 <= n; ++i) {
    if(isComposite(i) && isComposite(n - i)) {
        print(i, n - i);
        break;
    }
}

function isComposite(n) {
    for(var i = 2; i * i < n; ++i) {
        if(n % i == 0) {
            return true;
        }
    }
    return false;
}

var n = parseInt(readline());
for(var i = 4; i * 2 < n; ++i) {
    if(isComposite(i) && isComposite(n - i)) {
        print(i + " " + n);
        break;
    }
}

function isComposite(n) {
    for(var i = 2; i * i < n; ++i) {
        if(n % i == 0) {
            return true;
        }
    }
    return false;
}

var n = parseInt(readline());
for(var i = 4; i * 2 <= n; ++i) {
    if(isComposite(i) && isComposite(n - i)) {
        print(i, n);
        break;
    }
}

function isComposite(n) {
    for(var i = 2; i * i < n; ++i) {
        if(n % i == 0) {
            return true;
        }
    }
    return false;
}

var n = parseInt(readline())
for(var i = 4; i * 2 < n; ++i) {
    if(isComposite(i) && isComposite(n - i)) {
        print(i , n);
        break;
    }
}

var n = parseInt(readline());  // user input
print(n % 2 == 0 ? (4 + ' ' + n - 4) : (9 + ' ' + n - 9));

var n = parseInt(readline());  // user input
print(n % 2 == 0 ? (4, n - 4) : (9, n - 9));

var n = parseInt(readline());  // user input
if (n % 2 == 0) print(4 + ' ' + n - 4);
else print(9 + ' ' + n - 9);

var x= parseInt(readline());
for(var i=2; i<x; i++)
{
if(x%i==0) {var y=x/i; break;}
}
var z= parseInt(y/2)+1;
z*=i;
print(z+' '+ x-z);

function getTwoNums(num) {
    if(num >= 12 && num <= 1000000) {
    var numStr = num.toString();
    var numArr = numStr.split('');
    var firstNum = numArr.reduce(function(accumulator, current) {
    return Number(accumulator) + Number(current);
    })
    var secondNum = num - firstNum;
    return [firstNum, secondNum]
    }
    }
    var k = parseInt(readline());
    print(getTwoNums(k).join(' '))

var input = parseInt(readline());
if (input % 2) print(2 + ' ' + input - 2)
else print((input / 2) + 1 + ' ' + (input / 2) - 1)

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

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

readLine.on('close', () => {
  let nums = parseInt(input[0]);

  let left = 0, right = 0;
  if (nums % 2 === 0) { left = nums/2; right = nums/2; }
  else { left = (nums-1)/2; right = (nums+1)/2; }

  while (true) {
    if ( (left % 2 === 0 || left % 3 === 0 || left % 5 === 0 || (left % 7 === 0 && left !== 7)) &&
        (right % 2 === 0 || right % 3 === 0 || right % 5 === 0 || (right % 7 === 0 && right !== 7)) ) {
      console.log(`${left} ${right}`);
      break;
    } else {
      right -= 1; left += 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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let n = parseInt(readLine());
    if (n % 2 == 0) console.log(n / 2, n / 2)
    else console.log(n - 9, 9)
}