You are given a string $s$ consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string $s$ by '0' or '1' so that the string becomes a palindrome and has exactly $a$ characters '0' and exactly $b$ characters '1'. Note that each of the characters '?' is replaced independently from the others.

A string $t$ of length $n$ is called a palindrome if the equality $t[i] = t[n-i+1]$ is true for all $i$ ($1 \le i \le n$).

For example, if $s=$"01?????0", $a=4$ and $b=4$, then you can replace the characters '?' in the following ways:

"01011010";

"01100110".

For the given string $s$ and the numbers $a$ and $b$, replace all the characters with '?' in the string $s$ by '0' or '1' so that the string becomes a palindrome and has exactly $a$ characters '0' and exactly $b$ characters '1'.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$). Then $t$ test cases follow.

The first line of each test case contains two integers $a$ and $b$ ($0 \le a, b \le 2 \cdot 10^5$, $a + b \ge 1$).

The second line of each test case contains the string $s$ of length $a+b$, consisting of the characters '0', '1', and '?'.

It is guaranteed that the sum of the string lengths of $s$ over all test cases does not exceed $2 \cdot 10^5$.


-----Output-----

For each test case, output:

"-1", if you can't replace all the characters '?' in the string $s$ by '0' or '1' so that the string becomes a palindrome and that it contains exactly $a$ characters '0' and exactly $b$ characters '1';

the string that is obtained as a result of the replacement, otherwise.

If there are several suitable ways to replace characters, you can output any.


-----Examples-----

Input
9
4 4
01?????0
3 3
??????
1 0
?
2 2
0101
2 2
01?0
0 1
0
0 3
1?1
2 2
?00?
4 3
??010?0
Output
01011010
-1
0
-1
0110
-1
111
1001
0101010


-----Note-----

None

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Implementation

Constructive algorithms


Solutions:
import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(test,) = Neo()
for _ in range(test):
	(a, b) = Neo()
	s = list(input())
	n = len(s)
	a -= s.count('0')
	b -= s.count('1')
	if a < 0 or b < 0:
		print(-1)
		continue
	for i in range(n):
		if s[i] == '?':
			s[i] = s[n - i - 1]
			if s[i] == '0':
				a -= 1
			elif s[i] == '1':
				b -= 1
			else:
				s[i] = '*'
	if a < 0 or b < 0:
		print(-1)
		continue
	for i in range(n):
		if i == n // 2 and n % 2:
			continue
		if s[i] == '*':
			if a >= 2:
				s[i] = '0'
				s[n - i - 1] = '0'
				a -= 2
			else:
				s[i] = '1'
				s[n - i - 1] = '1'
				b -= 2
	if s[n // 2] == '*':
		if a > 0:
			s[n // 2] = '0'
			a -= 1
		else:
			s[n // 2] = '1'
			b -= 1
	if a != 0 or b != 0:
		print(-1)
	elif s != s[::-1]:
		print(-1)
	else:
		print(''.join(s))


import sys
import math
input = sys.stdin.readline
mod = 10 ** 9 + 7

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	(a, b) = invr()
	l = insr()
	a1 = 0
	b1 = 0
	c = 0
	n = a + b
	for i in range(n):
		if l[i] == '0':
			a1 += 1
		if l[i] == '1':
			b1 += 1
		if l[i] == '?':
			c += 1
	if a - a1 + b - b1 != c:
		print(-1)
		continue
	a = a - a1
	b = b - b1
	if a < 0 or b < 0:
		print(-1)
		continue
	s = 0
	for i in range(n):
		if l[i] != '?':
			if l[i] == '0':
				if l[n - i - 1] == '1':
					s = 1
				elif l[n - i - 1] == '?':
					l[n - i - 1] = '0'
					a = a - 1
					c = c - 1
			elif l[n - i - 1] == '0':
				s = 1
			elif l[n - i - 1] == '?':
				l[n - i - 1] = '1'
				b = b - 1
				c = c - 1
	if a < 0 or b < 0:
		print(-1)
		continue
	if s == 1:
		print(-1)
		continue
	if c == 0:
		print(''.join((str(i) for i in l)))
		continue
	if n % 2 == 1:
		if l[n // 2] == '?':
			if a % 2 == 1:
				l[n // 2] = '0'
				a -= 1
			else:
				l[n // 2] = '1'
				b -= 1
	if a % 2 == 1 or b % 2 == 1:
		print(-1)
		continue
	for i in range(n):
		if l[i] == '?':
			if a > 0:
				l[i] = '0'
				l[n - i - 1] = '0'
				a = a - 2
				continue
			if b > 0:
				l[i] = '1'
				l[n - i - 1] = '1'
				b = b - 2
	for i in range(n):
		if l[i] != l[n - i - 1]:
			s = 1
			break
	if s == 1:
		print(-1)
		continue
	print(''.join((str(i) for i in l)))


t = int(input())
while t:
	t -= 1
	(a0, b1) = map(int, input().split())
	a = list(input())
	n = len(a)
	l = 0
	r = n - 1
	cnt0 = 0
	cnt1 = 0
	flag = False
	while l <= r:
		if l == r:
			if a[l] == '0':
				cnt0 += 1
			if a[l] == '1':
				cnt1 += 1
			l += 1
			continue
		if a[l] == '?' or a[r] == '?':
			if a[l] == a[r] == '?':
				pass
			elif a[l] == '?':
				if a[r] == '0':
					a[l] = '0'
				else:
					a[l] = '1'
			elif a[l] == '0':
				a[r] = '0'
			else:
				a[r] = '1'
		if a[l] != a[r]:
			flag = True
			break
		if a[l] == '0':
			cnt0 += 2
		elif a[l] == '1':
			cnt1 += 2
		l += 1
		r -= 1
	if flag or cnt0 > a0 or cnt1 > b1:
		print(-1)
		continue
	for i in range(n // 2):
		if a[i] != '?':
			pass
		elif cnt0 + 2 <= a0:
			cnt0 += 2
			a[i] = a[n - 1 - i] = '0'
		elif cnt1 + 2 <= b1:
			cnt1 += 2
			a[i] = a[n - 1 - i] = '1'
			continue
		else:
			flag = True
			break
	if n % 2 != 0:
		i = n // 2
		if a[i] != '?':
			pass
		elif cnt0 < a0:
			cnt0 += 1
			a[i] = '0'
		elif cnt1 < b1:
			cnt1 += 1
			a[i] = '1'
		else:
			flag = True
			break
	if flag:
		print(-1)
		continue
	if cnt0 == a0 and cnt1 == b1:
		for elem in a:
			print(elem, end='')
		print()
	else:
		print(-1)


def solve(a, b, s):
	n = a + b
	m = n // 2
	for i in range(m):
		j = n - i - 1
		x = s[i]
		y = s[j]
		if x == '?' and y == '?':
			continue
		elif x == '0' and y == '0':
			a -= 2
		elif x == '0' and y == '1':
			return -1
		elif x == '0' and y == '?':
			s[j] = '0'
			a -= 2
		elif x == '1' and y == '0':
			return -1
		elif x == '1' and y == '1':
			b -= 2
		elif x == '1' and y == '?':
			s[j] = '1'
			b -= 2
		elif x == '?' and y == '0':
			s[i] = '0'
			a -= 2
		elif x == '?' and y == '1':
			s[i] = '1'
			b -= 2
	if n % 2 == 1:
		if s[m] == '0':
			a -= 1
		if s[m] == '1':
			b -= 1
	for i in range(m):
		j = n - i - 1
		if s[i] == '?':
			if a > 1:
				s[i] = '0'
				s[j] = '0'
				a -= 2
			elif b > 1:
				s[i] = '1'
				s[j] = '1'
				b -= 2
	if n % 2 == 1 and s[m] == '?':
		if a > 0:
			s[m] = '0'
			a -= 1
		elif b > 0:
			s[m] = '1'
			b -= 1
	if a < 0 or b < 0 or '?' in s:
		return -1
	return ''.join(s)
t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	s = list(input())
	print(solve(a, b, s))
	t -= 1


def main():
	t = int(input())
	for _ in range(t):
		(a, b) = (int(x) for x in input().split())
		s = input()
		print(solver(s, a, b))

def solver(s, a, b):
	if a + b != len(s):
		return -1
	a -= s.count('0')
	b -= s.count('1')
	result = [c for c in s]
	for i in range(len(s) // 2):
		left = s[i]
		right = s[len(s) - i - 1]
		if left != right:
			if left == '?' and right == '0':
				result[i] = '0'
				a -= 1
			elif left == '0' and right == '?':
				result[len(s) - i - 1] = '0'
				a -= 1
			elif left == '?' and right == '1':
				result[i] = '1'
				b -= 1
			elif left == '1' and right == '?':
				result[len(s) - i - 1] = '1'
				b -= 1
			else:
				return -1
	if a < 0 or b < 0:
		return -1
	if len(s) % 2 == 1:
		if result[len(s) // 2] == '?':
			if a % 2 == 1:
				result[len(s) // 2] = '0'
				a -= 1
			elif b % 2 == 1:
				result[len(s) // 2] = '1'
				b -= 1
			else:
				return -1
	for i in range(len(s) // 2):
		left = result[i]
		if left == '?':
			if a >= 2:
				result[i] = '0'
				result[len(s) - i - 1] = '0'
				a -= 2
			elif b >= 2:
				result[i] = '1'
				result[len(s) - i - 1] = '1'
				b -= 2
			else:
				return -1
	if a == 0 and b == 0:
		return ''.join(result)
	else:
		return -1

def solver2(s, a, b):
	a -= s.count('0')
	b -= s.count('1')
	result = [c for c in s]
	for i in range(len(s) // 2):
		left = s[i]
		right = s[len(s) - i - 1]
		if left != right:
			if left == '?' and right == '0':
				result[i] = '0'
				a -= 2
			elif left == '0' and right == '?':
				result[len(s) - i - 1] = '0'
				a -= 2
			elif left == '?' and right == '1':
				result[i] = '1'
				b -= 2
			elif left == '1' and right == '?':
				result[len(s) - i - 1] = '1'
				b -= 2
			else:
				return -1
	print(result)
	if a < 0 or b < 0:
		return -1
	if len(s) % 2 == 1:
		if result[len(s) // 2] == '?':
			if a % 2 == 1:
				result[len(s) // 2] = '0'
				a -= 1
			elif b % 2 == 1:
				result[len(s) // 2] = '1'
				b -= 1
			else:
				return -1
		elif result[len(s) // 2] == '0':
			a -= 1
		else:
			b -= 1
	print(a, b)
	for i in range(len(s) // 2):
		left = result[i]
		if left == '?':
			if a >= 2:
				result[i] = '0'
				result[len(s) - i - 1] = '0'
				a -= 2
			elif b >= 2:
				result[i] = '1'
				result[len(s) - i - 1] = '1'
				b -= 2
			else:
				return -1
		elif left == '0':
			a -= 2
		else:
			b -= 2
	if a == 0 and b == 0:
		return ''.join(result)
	else:
		return -1
main()


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	n = a + b
	bad = False
	s = list(input())
	assert len(s) == n
	for i in range(n // 2):
		j = n - i - 1
		if s[i] in '01' and s[j] in '01' and (s[i] != s[j]):
			bad = True
			break
		if s[i] != '?':
			s[j] = s[i]
		if s[j] != '?':
			s[i] = s[j]
	a -= s.count('0')
	b -= s.count('1')
	parities = (a % 2, b % 2)
	if bad or a < 0 or b < 0 or (0 not in parities) or (1 in parities and (n % 2 == 0 or s[n // 2] != '?')):
		print(-1)
		continue
	for i in range(n // 2):
		j = n - i - 1
		if s[i] == '?':
			if a >= b:
				s[i] = s[j] = '0'
				a -= 2
			else:
				s[i] = s[j] = '1'
				b -= 2
	if a == 1:
		s[n // 2] = '0'
		a = 0
	elif b == 1:
		s[n // 2] = '1'
		b = 0
	print(''.join(s) if a == 0 and b == 0 else -1)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = input()
	n = len(s)
	if a + b != n or (a % 2 == 1 and b % 2 == 1):
		print('-1')
	else:
		x = y = z = 0
		f = 0
		l1 = ['0'] * (n // 2)
		l2 = ['0'] * (n // 2)
		for i in range(n // 2):
			if s[i] == '0' and s[n - i - 1] == '1' or (s[i] == '1' and s[n - i - 1] == '0'):
				f = 1
				break
			elif s[i] == '0':
				x += 2
			elif s[i] == '1':
				l1[i] = '1'
				l2[n // 2 - i - 1] = '1'
				y += 2
			elif s[n - i - 1] == '0':
				x += 2
			elif s[n - i - 1] == '1':
				y += 2
				l1[i] = '1'
				l2[n // 2 - i - 1] = '1'
			else:
				l1[i] = '2'
				l2[n // 2 - i - 1] = '2'
				z += 2
		if f == 0:
			if n % 2 == 1:
				if s[n // 2] == '0':
					l1 += ['0']
					x += 1
				elif s[n // 2] == '1':
					l1 += ['1']
					y += 1
				elif a % 2 == 1:
					l1 += ['0']
					x += 1
				elif b % 2 == 1:
					l1 += ['1']
					y += 1
			for i in range(n // 2):
				if l1[i] == '2':
					if x < a:
						l1[i] = '0'
						l2[n // 2 - i - 1] = '0'
						x += 2
					else:
						l1[i] = '1'
						l2[n // 2 - i - 1] = '1'
						y += 2
			if x == a and y == b:
				print(''.join(l1), end='')
				print(''.join(l2))
			else:
				print('-1')
		else:
			print('-1')


import collections
t = int(input())
for _ in range(t):
	nosol = False
	(a, b) = [int(x) for x in input().split()]
	s = list(input())
	n = len(s)
	for i in range(n // 2):
		if s[i] == '?' or s[n - i - 1] == '?':
			if s[i] == '?':
				s[i] = s[n - i - 1]
			else:
				s[n - i - 1] = s[i]
		elif s[i] != '?' and s[n - i - 1] != '?' and (s[n - i - 1] != s[i]):
			nosol = True
	if nosol:
		nosol = False
		print(-1)
		continue
	c = collections.Counter(s)
	current_a = c.get('0', 0)
	current_b = c.get('1', 0)
	for i in range(n // 2):
		if current_a + 2 <= a and s[i] == '?':
			s[i] = '0'
			s[n - i - 1] = '0'
			current_a = current_a + 2
		elif current_b + 2 <= b and s[i] == '?':
			s[i] = '1'
			s[n - i - 1] = '1'
			current_b = current_b + 2
	if n % 2 != 0:
		if s[n // 2] == '?':
			if current_a < a:
				s[n // 2] = '0'
				current_a = current_a + 1
			elif current_b < b:
				s[n // 2] = '1'
				current_b = current_b + 1
	if current_a == a and current_b == b:
		print(''.join(s))
	else:
		print(-1)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	data = list(input())
	if a % 2 == 1 and b % 2 == 1:
		print(-1)
		continue
	log = {}
	log['0'] = a
	log['1'] = b
	size = a + b
	dead = False
	if size == 0:
		print('')
		continue
	if size == 1:
		trgt = '0' if a == 1 else '1'
		if data[0] == '?':
			data[0] = trgt
		elif data[0] != trgt:
			print(-1)
			continue
	for i in range(size // 2):
		if data[i] != data[size - 1 - i] and data[i] != '?' and (data[size - 1 - i] != '?'):
			dead = True
			break
		elif data[i] == data[size - 1 - i] and data[i] != '?':
			log[data[i]] -= 2
		elif data[i] == '?' and data[size - 1 - i] != '?':
			data[i] = data[size - 1 - i]
			log[data[i]] -= 2
		elif data[i] != '?' and data[size - 1 - i] == '?':
			data[size - 1 - i] = data[i]
			log[data[i]] -= 2
		if log['0'] < 0 or log['1'] < 0:
			dead = True
			break
	if dead:
		print(-1)
		continue
	for i in range(size // 2):
		if data[i] == '?' and data[size - i - 1] == '?':
			if log['0'] >= log['1'] and log['0'] >= 2:
				log['0'] -= 2
				data[i] = '0'
				data[size - i - 1] = '0'
			elif log['1'] > log['0'] and log['1'] >= 2:
				log['1'] -= 2
				data[i] = '1'
				data[size - i - 1] = '1'
			else:
				dead = True
				break
	if dead:
		print(-1)
		continue
	if size % 2 == 1:
		if data[size // 2] == '?':
			if log['0'] > 0:
				data[size // 2] = '0'
				log['0'] -= 1
			elif log['1'] > 0:
				data[size // 2] = '1'
				log['1'] -= 1
			else:
				dead = True
		else:
			trgt = '0' if log['0'] == 1 else '1'
			if data[size // 2] != trgt:
				dead = True
	if dead or log['0'] < 0 or log['1'] < 0:
		print(-1)
		continue
	else:
		print(''.join(data))


import os
import sys
import math
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def dijkstra(start, distance, path, n):
	visited = [False for _ in range(n)]
	distance[start] = 0
	for i in range(n):
		v = -1
		for j in range(n):
			if not visited[v] and (v == -1 or distance[j] < distance[v]):
				v = j
		if distance[v] == math.inf:
			break
		visited[v] = True
		for edge in adj[v]:
			destination = edge[0]
			weight = edge[1]
			if distance[v] + weight < distance[destination]:
				distance[destination] = distance[v] + weight
				path[destination] = v

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def npr(n, r):
	return math.factorial(n) // math.factorial(n - r)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 1
	while x * x <= n:
		if n % x == 0:
			if n // x == x:
				factors.append(x)
			else:
				factors.append(x)
				factors.append(n // x)
		x += 1
	return factors

def main():
	try:
		for _ in range(inp()):
			(a, b) = invr()
			n = a + b
			s = list(input())
			d = {'0': a, '1': b}
			for i in range(math.ceil(n / 2)):
				if i == n // 2:
					if s[i] != '?':
						d[s[i]] -= 1
					elif d['0'] & 1:
						s[i] = '0'
						d[s[i]] -= 1
					else:
						s[i] = '1'
						d[s[i]] -= 1
				elif s[i] != '?':
					if s[n - i - 1] == '?':
						s[n - i - 1] = s[i]
					d[s[i]] -= 2
				elif s[n - i - 1] != '?':
					if s[i] == '?':
						s[i] = s[n - i - 1]
					d[s[i]] -= 2
			for i in range(n // 2):
				if s[i] == '?':
					if d['0'] > d['1']:
						s[i] = '0'
						s[n - i - 1] = '0'
						d['0'] -= 2
					else:
						s[i] = '1'
						s[n - i - 1] = '1'
						d['1'] -= 2
			(c0, c1) = (0, 0)
			f = True
			for i in range(n):
				if s[i] == '1':
					c1 += 1
				else:
					c0 += 1
				if s[i] != s[n - i - 1]:
					f = False
					break
			if not f:
				print('-1')
			elif c0 == a and c1 == b and (d['0'] == 0) and (d['1'] == 0):
				print(*s, sep='')
			else:
				print('-1')
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input())
	n = a + b
	for i in range(n):
		if s[i] == '?':
			s[i] = s[n - i - 1]
	a = a - s.count('0')
	b = b - s.count('1')
	for i in range(n // 2 + 1):
		if s[i] == '?' and i != n // 2:
			if a > 1:
				s[i] = s[n - i - 1] = '0'
				a -= 2
			elif b > 1:
				s[i] = s[n - i - 1] = '1'
				b -= 2
		elif s[i] == '?':
			if a > 0:
				s[i] = '0'
				a -= 1
			elif b > 0:
				s[i] = '1'
				b -= 1
	if s == s[::-1] and a == b == 0:
		print(''.join(s))
	else:
		print(-1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	S = list(input())[:-1]
	n = a + b
	a -= S.count('0')
	b -= S.count('1')
	for i in range(n):
		j = n - 1 - i
		if S[i] == '0':
			if S[j] == '?':
				a -= 1
				S[j] = '0'
			if S[j] == '1':
				break
		if S[i] == '1':
			if S[j] == '?':
				b -= 1
				S[j] = '1'
			if S[j] == '0':
				break
	else:
		for i in range(n):
			j = n - 1 - i
			if S[i] != '?':
				continue
			if i != j:
				if a >= 2:
					a -= 2
					S[i] = '0'
					S[j] = '0'
				elif b >= 2:
					b -= 2
					S[i] = '1'
					S[j] = '1'
			elif a % 2:
				a -= 1
				S[i] = '0'
			elif b % 2:
				b -= 1
				S[i] = '1'
		if '?' in S or a or b:
			print(-1)
			continue
		print(''.join(S))
		continue
	print(-1)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = input()
	coun0 = s.count('0')
	coun1 = s.count('1')
	temp1 = a - coun0
	temp2 = b - coun1
	l = list()
	l.extend(s)
	i = 0
	j = len(l) - 1
	f = 0
	if coun0 > a or coun1 > b:
		print(-1)
		continue
	while i <= j:
		if i == j and l[i] == '?':
			if temp1 % 2 == 1:
				l[i] = '0'
				temp1 -= 1
			elif temp2 % 2 == 1:
				l[i] = '1'
				temp2 -= 1
			else:
				f = 1
				break
		elif l[i] != '?' and l[j] != '?':
			if l[i] == l[j]:
				pass
			else:
				f = 1
				break
		elif l[i] == '?' and l[j] == '?':
			pass
		elif l[i] == '?':
			if l[j] == '1' and temp2:
				temp2 -= 1
				l[i] = '1'
			elif l[j] == '0' and temp1:
				temp1 -= 1
				l[i] = '0'
			else:
				f = 1
				break
		elif l[i] == '1' and temp2:
			temp2 -= 1
			l[j] = '1'
		elif l[i] == '0' and temp1:
			temp1 -= 1
			l[j] = '0'
		else:
			f = 1
			break
		i += 1
		j -= 1
	i = 0
	j = len(l) - 1
	while i <= j:
		if l[i] == '?' and l[j] == '?':
			if temp1 >= 2:
				l[i] = '0'
				l[j] = '0'
				temp1 -= 2
			elif temp2 >= 2:
				l[i] = '1'
				l[j] = '1'
				temp2 -= 2
		i += 1
		j -= 1
	if f == 0 and temp1 == 0 and (temp2 == 0):
		print(''.join(l))
	else:
		print(-1)


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	s = list(input())
	poss = True
	n = a + b
	mark = [0] * n
	for i in range(n):
		if s[i] == '0' and (not mark[i]):
			a -= 1
			mark[i] = 1
			if s[n - i - 1] == '?':
				s[n - i - 1] = '0'
				a -= 1
				mark[n - i - 1] = 1
		elif s[i] == '1' and (not mark[i]):
			b -= 1
			mark[i] = 1
			if s[n - i - 1] == '?':
				s[n - i - 1] = '1'
				b -= 1
				mark[n - i - 1] = 1
	for i in range(n):
		if s[i] == '?':
			if i == n // 2 and s[i] == '?':
				if a % 2:
					s[i] = '0'
					a -= 1
				elif b % 2:
					s[i] = '1'
					b -= 1
				else:
					poss = not poss
			elif a > 1:
				s[i] = '0'
				s[n - i - 1] = '0'
				a -= 2
			elif b > 1:
				s[i] = '1'
				s[n - i - 1] = '1'
				b -= 2
	if (a != 0 or b != 0) or (a % 2 and b % 2) or s != s[::-1]:
		poss = not poss
	print(''.join(s) if poss else -1)


from sys import stdin, stdout
import sys
import math
import itertools
from collections import defaultdict
sys.setrecursionlimit(10 ** 6)

def abpalin(a, b, stri):
	n = a + b
	s = []
	for i in stri:
		s.append(i)
	for i in range(n):
		if s[i] != '?':
			if s[n - i - 1] == '?':
				s[n - i - 1] = s[i]
			elif s[i] != s[n - i - 1]:
				return -1
	for i in range(n - 1, -1, -1):
		if s[i] != '?':
			if s[n - i - 1] == '?':
				s[n - i - 1] = s[i]
			elif s[i] != s[n - i - 1]:
				return -1
	ques = 0
	for i in range(n):
		if s[i] == '0':
			a -= 1
		elif s[i] == '1':
			b -= 1
		else:
			ques += 1
	if a + b != ques:
		return -1
	if (a % 2 == 1 or b % 2 == 1) and s[n // 2] != '?':
		return -1
	if n % 2 == 1 and s[n // 2] == '?':
		if a % 2 == 1:
			s[n // 2] = '0'
			a -= 1
		elif b % 2 == 1:
			s[n // 2] = '1'
			b -= 1
		else:
			return -1
	for i in range(n):
		if s[i] == '?':
			if a > 1:
				s[i] = s[n - i - 1] = '0'
				a -= 2
			elif b > 1:
				s[i] = s[n - i - 1] = '1'
				b -= 2
			else:
				return -1
	if a == b == 0:
		return s
	else:
		return -1

def main():
	t = int(stdin.readline().strip())
	for i in range(1, t + 1):
		(a, b) = map(int, stdin.readline().split())
		s = stdin.readline().strip()
		ans = abpalin(a, b, s)
		if ans == -1:
			stdout.write('-1\n')
		else:
			for j in ans:
				print(j, end='')
			print()
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = []
	s = input()
	for i in s:
		l.append(i)
	n = len(s)
	i = 0
	f = 0
	q = 0
	while i < n // 2:
		if l[i] == '?' and l[n - i - 1] == '?':
			q += 2
		elif l[i] == '?':
			l[i] = l[n - i - 1]
		elif l[n - i - 1] == '?':
			l[n - i - 1] = l[i]
		elif l[i] != l[n - i - 1]:
			f = 1
			break
		i += 1
	if f == 1:
		print(-1)
	else:
		na = l.count('0')
		nb = l.count('1')
		ra = a - na
		rb = b - nb
		if ra >= 0 and rb >= 0:
			for i in range(n // 2):
				if l[i] == '?':
					if ra >= 2:
						l[i] = '0'
						l[n - i - 1] = '0'
						ra -= 2
					elif rb >= 2:
						l[i] = '1'
						l[n - i - 1] = '1'
						rb -= 2
			if n % 2 == 1:
				if l[n // 2] == '?':
					if ra == 1:
						l[n // 2] = '0'
					else:
						l[n // 2] = '1'
			if '?' in l:
				print(-1)
			else:
				print(''.join(l))
		else:
			print(-1)


T = int(input())
for _ in range(T):
	(zeroes, ones) = map(int, input().split())
	string = list(input())
	if zeroes % 2 and ones % 2:
		print(-1)
		continue
	start = 0
	end = len(string) - 1
	while start <= end:
		if string[start] != '?' and string[end] != '?' and (string[start] != string[end]):
			print(-1)
			break
		elif string[start] == '?' and string[end] != '?':
			string[start] = string[end]
		elif string[start] != '?' and string[end] == '?':
			string[end] = string[start]
		if string[start] == '0':
			if start == end:
				zeroes -= 1
			else:
				zeroes -= 2
		elif string[start] == '1':
			if start == end:
				ones -= 1
			else:
				ones -= 2
		if zeroes < 0 or ones < 0:
			print(-1)
			break
		start += 1
		end -= 1
	else:
		start = 0
		end = len(string) - 1
		while start < end:
			if string[start] == '?':
				if zeroes > 1:
					string[start] = '0'
					string[end] = '0'
					zeroes -= 2
				else:
					if ones < 2:
						print(-1)
						break
					else:
						string[start] = '1'
					string[end] = '1'
					ones -= 2
			start += 1
			end -= 1
		else:
			if start == end and string[start] == '?':
				if zeroes == 1:
					string[start] = '0'
				elif ones == 1:
					string[start] = '1'
				else:
					print(-1)
					break
			elif zeroes != 0 or ones != 0:
				print(-1)
				break
			ans = ''
			print(ans.join(string))


from sys import stdin, stdout

def palindrome(s):
	if s == s[::-1]:
		return True
	return False

def main():
	for _ in range(int(stdin.readline())):
		(a, b) = map(int, stdin.readline().split())
		s = list(stdin.readline()[:-1])
		n = len(s)
		a -= s.count('0')
		b -= s.count('1')
		end = False
		for i in range(n // 2):
			j = n - 1 - i
			if s[i] != s[j] and s[i] != '?' and (s[j] != '?'):
				stdout.write('-1\n')
				end = True
				break
			elif s[i] == '?':
				if s[j] == '0':
					s[i] = '0'
					a -= 1
				elif s[j] == '1':
					s[i] = '1'
					b -= 1
				else:
					continue
			elif s[j] == '?':
				if s[i] == '0':
					s[j] = '0'
					a -= 1
				elif s[i] == '1':
					s[j] = '1'
					b -= 1
			if a < 0 or b < 0:
				stdout.write('-1\n')
				end = True
				break
		if end == False:
			for i in range(n // 2):
				j = n - 1 - i
				if s[i] == '?':
					if a > b:
						s[i] = '0'
						s[j] = '0'
						a -= 2
					else:
						s[i] = '1'
						s[j] = '1'
						b -= 2
				if a < 0 or b < 0:
					stdout.write('-1\n')
					end = True
					break
		if end == False:
			if n & 1 and s[n // 2] == '?':
				if a > b:
					s[n // 2] = '0'
					a -= 1
				else:
					s[n // 2] = '1'
					b -= 1
			if a == 0 and b == 0:
				print(*s, sep='')
			else:
				stdout.write('-1\n')
main()


T = int(input())
for e in range(T):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	n = a + b
	t = list(input())
	flag = 0
	for i in range(n):
		(l1, l2) = (t[i], t[n - i - 1])
		if l1 != '?' and l2 != '?':
			if l1 != l2:
				print(-1)
				flag = 1
				break
			elif l1 == '0':
				a = a - 1
			else:
				b = b - 1
		elif l1 == '?' and l2 == '?':
			continue
		elif l1 == '?':
			if l2 == '0':
				a = a - 1
				t[i] = '0'
			else:
				b = b - 1
				t[i] = '1'
		elif l2 == '?':
			if l1 == '0':
				a = a - 1
				t[n - i - 1] = '0'
			else:
				b = b - 1
				t[n - i - 1] = '1'
	if flag == 0:
		for i in range(n):
			(l1, l2) = (t[i], t[n - i - 1])
			if l1 == '?' and l2 == '?':
				if i == n - i - 1:
					if a % 2 != 0:
						t[i] = '0'
						a = a - 1
					else:
						t[i] = '1'
						b = b - 1
				elif a > b:
					(t[i], t[n - i - 1]) = ('0', '0')
					a = a - 2
				else:
					(t[i], t[n - i - 1]) = ('1', '1')
					b = b - 2
		if a == 0 and b == 0:
			print(''.join(t))
		else:
			print(-1)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	s = input()
	ans = [-1] * len(s)
	n = len(s)
	for i in range(len(s)):
		if s[i] == '0':
			ans[i] = '0'
			a -= 1
		elif s[i] == '1':
			ans[i] = '1'
			b -= 1
		elif s[n - i - 1] == '0':
			ans[i] = '0'
			a -= 1
		elif s[n - i - 1] == '1':
			ans[i] = '1'
			b -= 1
		else:
			ans[i] = '?'
	for i in range(len(ans) // 2):
		if ans[i] == '?':
			if a >= 2:
				ans[i] = '0'
				ans[n - i - 1] = '0'
				a -= 2
			else:
				ans[i] = '1'
				ans[n - i - 1] = '1'
				b -= 2
	if n % 2:
		if ans[n // 2] == '?':
			if a >= 1:
				ans[n // 2] = '0'
				a -= 1
			else:
				ans[n // 2] = '1'
				b -= 1
	answer = ''.join(ans)
	if answer == answer[::-1] and a == 0 and (b == 0):
		print(answer)
	else:
		print(-1)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	n = a + b
	s = list(input())
	result = float('-inf')
	for i in range(n):
		if s[n - i - 1] == '?' and s[i] != '?':
			s[n - i - 1] = s[i]
		elif s[i] != '?' and s[n - i - 1] != '?' and (s[i] != s[n - i - 1]):
			result = -1
			break
	a = a - s.count('0')
	b = b - s.count('1')
	if a < 0 or b < 0 or a + b != s.count('?'):
		print(-1)
		continue
	if result == -1:
		print(-1)
		continue
	if n % 2 != 0:
		if s[n // 2] == '?':
			if a % 2 != 0:
				s[n // 2] = '0'
				a -= 1
			elif b % 2 != 0:
				s[n // 2] = '1'
				b -= 1
			else:
				result = -1
				break
	if result == -1:
		print(-1)
		continue
	if a % 2 == 1 or b % 2 == 1:
		print(-1)
		continue
	for i in range(n):
		if s[i] == '?':
			if a > 0:
				s[i] = '0'
				s[n - i - 1] = '0'
				a -= 2
			elif b > 0:
				s[i] = '1'
				s[n - i - 1] = '1'
				b -= 2
	print(''.join(s))


def test():
	(a, b) = map(int, input().split())
	s = list(input())
	n = a + b
	if a % 2 and b % 2:
		print(-1)
		return
	for i in range(n // 2):
		if s[i] == '?' and s[n - 1 - i] != '?':
			s[i] = s[n - 1 - i]
		elif s[i] != '?' and s[n - 1 - i] == '?':
			s[n - 1 - i] = s[i]
		elif s[i] != '?' and s[n - 1 - i] != '?' and (s[i] != s[n - 1 - i]):
			print(-1)
			return
	if n % 2 and a % 2 and (s[n // 2] == '?'):
		s[n // 2] = '0'
	if n % 2 and b % 2 and (s[n // 2] == '?'):
		s[n // 2] = '1'
	for i in range(n):
		if s[i] == '0':
			a -= 1
		elif s[i] == '1':
			b -= 1
	if a < 0 or b < 0 or a % 2 or b % 2:
		print(-1)
		return
	for i in range(n // 2):
		if s[i] == '?' and a > 0:
			s[i] = '0'
			s[n - 1 - i] = '0'
			a -= 2
		elif s[i] == '?' and b > 0:
			s[i] = '1'
			s[n - 1 - i] = '1'
			b -= 2
	if a != 0 or b != 0:
		print(-1)
	else:
		print(''.join(s))
t = int(input())
while t:
	test()
	t -= 1


for _ in range(int(input())):
	(a_0, a_1) = map(int, input().split())
	s = list(input().strip())
	n = len(s)
	for i in range(n):
		if s[i] == '?':
			s[i] = s[n - i - 1]
	a_0 -= s.count('0')
	a_1 -= s.count('1')
	for i in range(n // 2 + 1):
		if i != n - i - 1 and s[i] == '?':
			if a_0 > 1:
				s[i] = s[n - i - 1] = '0'
				a_0 -= 2
			elif a_1 > 1:
				s[i] = s[n - i - 1] = '1'
				a_1 -= 2
		elif s[i] == '?':
			if a_0 > 0:
				s[i] = '0'
				a_0 -= 1
			elif a_1 > 0:
				s[i] = '1'
				a_1 -= 1
	s = ''.join(s)
	if s == s[::-1] and a_0 == a_1 == 0:
		print(s)
	else:
		print(-1)


t = int(input())
for www in range(t):
	(a, b) = map(int, input().split())
	st = [i for i in input()]
	n = len(st)
	for i in range(n // 2):
		if st[i] == '1' and st[n - i - 1] == '0' or (st[i] == '0' and st[n - i - 1] == '1'):
			print(-1)
			break
		if st[i] == '?':
			st[i] = st[n - i - 1]
		elif st[n - i - 1] == '?':
			st[n - i - 1] = st[i]
		if st[i] == '0':
			a -= 2
		if st[i] == '1':
			b -= 2
	else:
		check = False
		for i in range(n // 2):
			if st[i] == '?':
				if a >= 2:
					a -= 2
					st[i] = '0'
					st[n - i - 1] = '0'
				elif b >= 2:
					b -= 2
					st[i] = '1'
					st[n - i - 1] = '1'
				else:
					check = True
			if check or a < 0 or b < 0:
				print(-1)
				break
		else:
			if n % 2 == 1:
				if st[n // 2] == '1':
					b -= 1
				elif st[n // 2] == '0':
					a -= 1
				elif a > 0:
					a -= 1
					st[n // 2] = '0'
				else:
					b -= 1
					st[n // 2] = '1'
			if a == 0 and b == 0:
				for i in st:
					print(i, end='')
				print()
			else:
				print(-1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input().rstrip())
	l = len(s)
	question = s.count('?')
	f = 0
	for i in range(0, l // 2):
		left = s[i]
		right = s[l - 1 - i]
		if left == right:
			if left == '0':
				a -= 2
			elif left == '1':
				b -= 2
		elif left == '?':
			question -= 1
			if right == '0':
				a -= 2
				s[i] = '0'
			else:
				b -= 2
				s[i] = '1'
		elif right == '?':
			question -= 1
			if left == '0':
				a -= 2
				s[l - 1 - i] = '0'
			else:
				b -= 2
				s[l - 1 - i] = '1'
		else:
			print(-1)
			f = 1
			break
	if f == 0:
		if l % 2 == 1:
			if s[l // 2] == '0':
				a -= 1
			elif s[l // 2] == '1':
				b -= 1
			elif a % 2 == 1:
				a -= 1
				s[l // 2] = '0'
				question -= 1
			elif b % 2 == 1:
				b -= 1
				s[l // 2] = '1'
				question -= 1
			else:
				print(-1)
				continue
		if a < 0 or b < 0 or a % 2 == 1 or (b % 2 == 1) or (a + b != question):
			print(-1)
			continue
		for i in range(0, l // 2):
			if s[i] == '?':
				if a > 0:
					s[i] = s[l - 1 - i] = '0'
					a -= 2
				else:
					s[i] = s[l - 1 - i] = '1'
					b -= 2
		for x in s:
			print(x, end='')
		print()


from bisect import *
import math
from collections import *
from heapq import *
from itertools import *
inf = 10 ** 18
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input())
	n = len(s)
	ans = True
	a -= s.count('0')
	b -= s.count('1')
	for i in range(n):
		if s[i] == '?' and s[n - i - 1] != '?':
			s[i] = s[n - i - 1]
			if s[n - i - 1] == '0':
				a -= 1
			else:
				b -= 1
	if a < 0 or b < 0:
		ans = False
	for i in range(n):
		if s[i] == '?' and s[n - i - 1] == '?' and (i != n - i - 1):
			if a >= 2:
				s[i] = '0'
				s[n - i - 1] = '0'
				a -= 2
			elif b >= 2:
				s[i] = '1'
				s[n - i - 1] = '1'
				b -= 2
			else:
				ans = False
				break
		elif s[i] == '?' and i == n - i - 1:
			if a % 2:
				s[i] = '0'
				a -= 1
			elif b % 2:
				s[i] = '1'
				b -= 1
			else:
				ans = False
				break
	if ans and s == s[::-1] and (s.count('?') == 0):
		print(''.join(s))
	else:
		print(-1)


import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
import string

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None
		self.BUFSIZE = 8192

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def get_int():
	return int(input())

def get_ints():
	return list(map(int, input().split(' ')))

def get_int_grid(n):
	return [get_ints() for _ in range(n)]

def get_str():
	return input().strip()

def get_strs():
	return get_str().split(' ')

def flat_list(arr):
	return [item for subarr in arr for item in subarr]

def yes_no(b):
	if b:
		return 'YES'
	else:
		return 'NO'

def binary_search(good, left, right, delta=1, right_true=False):
	limits = [left, right]
	while limits[1] - limits[0] > delta:
		if delta == 1:
			mid = sum(limits) // 2
		else:
			mid = sum(limits) / 2
		if good(mid):
			limits[int(right_true)] = mid
		else:
			limits[int(~right_true)] = mid
	if good(limits[int(right_true)]):
		return limits[int(right_true)]
	else:
		return False

def prefix_sums(a):
	p = [0]
	for x in a:
		p.append(p[-1] + x)
	return p

def solve_a():
	n = get_int()
	x = get_ints()
	x_enum = [(v, i) for (i, v) in enumerate(x)]
	x_enum.sort()
	if x_enum[0][0] != x_enum[1][0]:
		return x_enum[0][1] + 1
	else:
		return x_enum[-1][1] + 1

def solve_b():
	n = get_int()
	grid = [list(get_str()) for row in range(n)]
	points = []
	for i in range(n):
		for j in range(n):
			if grid[i][j] == '*':
				points.append((i, j))
	(a, b) = points
	if a[0] != b[0] and a[1] != b[1]:
		grid[a[0]][b[1]] = '*'
		grid[b[0]][a[1]] = '*'
	elif a[0] == b[0]:
		new = (a[0] + 1) % n
		grid[new][a[1]] = '*'
		grid[new][b[1]] = '*'
	elif a[1] == b[1]:
		new = (a[1] + 1) % n
		grid[a[0]][new] = '*'
		grid[b[0]][new] = '*'
	for row in grid:
		print(''.join(row))
	return

def solve_c():
	(a, b) = get_ints()
	s = list(get_str())
	a -= s.count('0')
	b -= s.count('1')
	n = len(s)
	for i in range(n):
		if s[i] == '1' and s[n - i - 1] == '?':
			s[n - i - 1] = '1'
			b -= 1
		if s[i] == '0' and s[n - i - 1] == '?':
			s[n - i - 1] = '0'
			a -= 1
	for i in range(n):
		if i != n - i - 1 and s[i] == s[n - i - 1] == '?':
			if a > 1:
				s[n - i - 1] = '0'
				s[i] = '0'
				a -= 2
			elif b > 1:
				s[n - i - 1] = '1'
				s[i] = '1'
				b -= 2
			else:
				return -1
	if s[n // 2] == '?':
		if a > 0:
			s[n // 2] = '0'
			a -= 1
		elif b > 0:
			s[n // 2] = '1'
			b -= 1
		else:
			return -1
	for i in range(n):
		if s[i] != s[n - i - 1]:
			return -1
	if a != 0 or b != 0:
		return -1
	else:
		return ''.join(s)
t = get_int()
for _ in range(t):
	print(solve_c())


from sys import stdin
input = stdin.readline
from heapq import heapify, heappush, heappop, heappushpop
from collections import defaultdict as dd, deque as dq, Counter as C
from math import factorial as f, ceil, gcd, sqrt, log
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations as c, permutations as p
from math import factorial as f, ceil, gcd, sqrt, log
mp = lambda : map(int, input().split())
it = lambda : int(input())
ls = lambda : list(input().strip())
mt = lambda r: [ls() for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)

def fibo_n(n):
	return ((1 + sqrt(5)) / 2) ** n / sqrt(5)
mod = 1000000007
for _ in range(it()):
	(a, b) = mp()
	l = ls()
	k = len(l) // 2
	if len(l) & 1:
		rem = len(l) // 2
	v = []
	zero = a
	ones = b
	ans = 1
	for i in range(k):
		if l[i] == l[-1 - i] == '?':
			v.append(i)
		elif l[i] == l[-1 - i]:
			if l[i] == '0':
				zero -= 2
			else:
				ones -= 2
		elif l[i] == '?' and l[-1 - i] in '01':
			l[i] = l[-1 - i]
			if l[i] == '0':
				zero -= 2
			else:
				ones -= 2
		elif l[i] in '01' and l[-1 - i] == '?':
			l[-1 - i] = l[i]
			if l[i] == '0':
				zero -= 2
			else:
				ones -= 2
		else:
			ans = -1
			break
	if ans == -1 or zero < 0 or ones < 0:
		print(-1)
	else:
		for i in range(zero // 2):
			l[v[i]] = '0'
			l[-1 - v[i]] = '0'
			zero -= 2
		if len(l) & 1 and zero == 1 and (l[rem] in '0?'):
			l[rem] = '0'
			zero -= 1
		for i in range(len(l)):
			if l[i] == '?':
				l[i] = '1'
				ones -= 1
		if len(l) & 1 and ones == 1 and (l[rem] == '1'):
			ones -= 1
		if ones == 0 and zero == 0:
			print(''.join(l))
		else:
			print(-1)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	arr = list(input())
	n = a + b
	mid = n % 2 and arr[n // 2] == '?'
	repeats = []
	a_ = 0
	b_ = 0
	if n % 2:
		if arr[n // 2] == '0':
			a_ += 1
		elif arr[n // 2] == '1':
			b_ += 1
	for i in range(n // 2):
		if arr[i] != arr[-i - 1]:
			if arr[i] == '?':
				arr[i] = arr[-i - 1]
			elif arr[-i - 1] == '?':
				arr[-i - 1] = arr[i]
			else:
				print(-1)
				break
		elif arr[i] == '?':
			repeats.append(i)
		if arr[i] == '0':
			a_ += 1
		elif arr[i] == '1':
			b_ += 1
		if arr[-i - 1] == '0':
			a_ += 1
		elif arr[-i - 1] == '1':
			b_ += 1
	else:
		if mid:
			if (a - a_) % 2 == (b - b_) % 2 == 0:
				print(-1)
				continue
			elif (a - a_) % 2:
				arr[n // 2] = '0'
				a_ += 1
			elif (b - b_) % 2:
				arr[n // 2] = '1'
				b_ += 1
		for i in repeats:
			if a - a_ >= 2:
				a_ += 2
				arr[i] = '0'
				arr[-i - 1] = '0'
			elif b - b_ >= 2:
				b_ += 2
				arr[i] = '1'
				arr[-i - 1] = '1'
		if a_ == a and b_ == b:
			print(*arr, sep='')
		else:
			print(-1)


def helper(s, a, b):
	l = a + b
	pool = [''] * l
	for j in range((l + 1) // 2):
		if s[j] == '0' and s[l - j - 1] == '1' or (s[j] == '1' and s[l - j - 1] == '0'):
			return '-1'
		if j == l - j - 1 and s[j] == '0':
			a -= 1
			pool[j] = '0'
		elif j == l - j - 1 and s[j] == '1':
			b -= 1
			pool[j] = '1'
		elif s[j] == '0' or s[l - j - 1] == '0':
			a -= 2
			pool[j] = '0'
			pool[l - j - 1] = '0'
		elif s[j] == '1' or s[l - j - 1] == '1':
			b -= 2
			pool[j] = '1'
			pool[l - j - 1] = '1'
	for j in range((l + 1) // 2):
		if pool[j] == '' and j != l - j - 1:
			if a >= b:
				a -= 2
				pool[j] = '0'
				pool[l - j - 1] = '0'
			else:
				b -= 2
				pool[j] = '1'
				pool[l - j - 1] = '1'
		if pool[j] == '' and j == l - j - 1:
			if a >= b:
				a -= 1
				pool[j] = '0'
			else:
				b -= 1
				pool[j] = '1'
	if a != 0 or b != 0:
		return '-1'
	return ''.join(pool)
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split(' '))
	s = input()
	print(helper(s, a, b))


tc = int(input())
for _ in range(tc):
	(a, b) = list(map(int, input().split()))
	l = list(input())
	works = True
	for (i, c) in enumerate(l):
		if c != '?':
			if l[-i - 1] == '?':
				l[-i - 1] = c
			elif l[-i - 1] != c:
				works = False
				break
	if not works:
		print(-1)
		continue
	zs = a - l.count('0')
	os = b - l.count('1')
	i = 0
	while (zs > 0 or os > 0) and i < len(l):
		if l[i] == '?':
			if zs > 1 or (zs > 0 and i == len(l) - i - 1):
				l[i] = '0'
				zs -= 1
				if i != len(l) - i - 1:
					l[-i - 1] = '0'
					zs -= 1
			elif os > 1 or (os > 0 and i == len(l) - i - 1):
				l[i] = '1'
				os -= 1
				if i != len(l) - i - 1:
					l[-i - 1] = '1'
					os -= 1
			else:
				works = False
				break
		i += 1
	if not works or l.count('0') != a or l.count('1') != b or (l.count('?') > 0):
		print(-1)
	else:
		for c in l:
			print(c, end='')
		print()


import os
import sys
from collections import Counter
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		(a, b) = map(int, input().split())
		s = list(input())
		n = a + b
		aa = 0
		bb = 0
		f = 0
		for i in range(int(n / 2)):
			if s[i] != s[n - i - 1]:
				if s[i] != '?' and s[n - i - 1] != '?':
					print(-1)
					f = 1
					break
				elif s[i] == '?' and s[n - i - 1] == '?':
					pass
				elif s[i] == '?':
					s[i] = s[n - i - 1]
				else:
					s[n - i - 1] = s[i]
		aa = s.count('0')
		bb = s.count('1')
		if f == 0:
			for i in range(int(n / 2)):
				if s[i] == '?':
					if aa + 2 <= a:
						s[i] = '0'
						s[n - i - 1] = '0'
						aa += 2
					else:
						s[i] = '1'
						s[n - i - 1] = '1'
						bb += 2
			if n % 2 != 0 and s[n // 2] == '?':
				if aa + 1 <= a:
					aa += 1
					s[n // 2] = '0'
				else:
					bb += 1
					s[n // 2] = '1'
			if s != s[::-1] or s.count('0') != a or s.count('1') != b:
				print(-1)
			else:
				print(''.join(s))
main()


t = int(input())

def solve(a: int, b: int, s: str):
	n = a + b
	ns = list(s)
	if n % 2 == 1 and ns[n // 2] == '?':
		if a % 2 == 1:
			ns[n // 2] = '0'
		elif b % 2 == 1:
			ns[n // 2] = '1'
		else:
			return -1
	a -= ns.count('0')
	b -= ns.count('1')
	if a < 0 or b < 0:
		return -1
	for i in range(n):
		cpi = n - i - 1
		if ns[i] != '?':
			if ns[cpi] == '?':
				ns[cpi] = ns[i]
				if ns[i] == '0' and a > 0:
					a -= 1
				elif ns[i] == '1' and b > 0:
					b -= 1
				else:
					return -1
			elif ns[cpi] != ns[i]:
				return -1
	for i in range(n // 2):
		cpi = n - i - 1
		if ns[i] == ns[cpi] == '?':
			if a > 1:
				ns[i] = ns[cpi] = '0'
				a -= 2
			elif b > 1:
				ns[i] = ns[cpi] = '1'
				b -= 2
			else:
				return -1
	return ''.join(ns)
for _ in range(t):
	(a, b) = map(int, input().split())
	ans = solve(a, b, input())
	print(ans)


import sys
import math
mod = 10 ** 9 + 7
LI = lambda : [int(k) for k in input().split()]
input = lambda : sys.stdin.readline().rstrip()
IN = lambda : int(input())
S = lambda : input()
for t in range(IN()):
	(a, b) = LI()
	t = a + b
	s = S()
	s = list(s)
	flag = 1
	if a % 2 == 1 and b % 2 == 1:
		flag = 0
	if flag == 0:
		print(-1)
		continue
	aa = 0
	ab = 0
	for i in range(a + b):
		if s[i] == '0':
			if s[a + b - 1 - i] == '1':
				flag = 0
				break
			aa += 1
		elif s[i] == '1':
			if s[a + b - 1 - i] == '0':
				flag = 0
				break
			ab += 1
	la = a - aa
	lb = b - ab
	if la < 0 or lb < 0:
		flag = 0
	if flag == 0:
		print(-1)
		continue
	for i in range(a + b):
		if s[i] == '?' and s[t - 1 - i] == '0':
			if la >= 1:
				s[i] = '0'
				la -= 1
			else:
				flag = 0
				break
		elif s[i] == '0' and s[t - 1 - i] == '?':
			if la >= 1:
				s[t - 1 - i] = '0'
				la -= 1
			else:
				flag = 0
				break
		elif s[i] == '?' and s[t - 1 - i] == '1':
			if lb >= 1:
				s[i] = '1'
				lb -= 1
			else:
				flag = 0
				break
		elif s[i] == '1' and s[t - 1 - i] == '?':
			if lb >= 1:
				s[t - 1 - i] = '1'
				lb -= 1
			else:
				flag = 0
				break
	for i in range((t + 1) // 2):
		if s[i] == '?' and s[t - 1 - i] == '?' and (i != a + b - 1 - i):
			if la >= lb and la >= 2:
				s[i] = '0'
				s[t - 1 - i] = '0'
				la -= 2
			elif lb >= la and lb >= 2:
				s[i] = '1'
				s[t - 1 - i] = '1'
				lb -= 2
			else:
				flag = 0
				break
		elif s[i] == '?' and s[t - 1 - i] == '?' and (i == a + b - 1 - i):
			if a % 2 == 1 and la >= 1:
				s[i] = '0'
				la -= 1
			elif b % 2 == 1 and lb >= 1:
				s[i] = '1'
				lb -= 1
			else:
				flag = 0
				break
	if flag == 0:
		print(-1)
		continue
	else:
		for i in range(a + b):
			print(s[i], end='')
		print()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list((c for c in input()))
	vals = [a - s.count('0'), b - s.count('1')]
	t = len(s)
	d = t // 2 if t % 2 == 0 else t // 2 + 1
	for i in range(d):
		if s[i] != s[t - 1]:
			if s[i] == '?':
				s[i] = s[t - 1]
				vals[ord(s[t - 1]) - 48] -= 1
			elif s[t - 1] == '?':
				s[t - 1] = s[i]
				vals[ord(s[i]) - 48] -= 1
			else:
				vals[0] = -250000
				break
		t -= 1
	t = a + b
	for i in range(d):
		if s[i] == '?':
			s[i] = '0' if max(vals) == vals[0] else '1'
			s[t - 1] = s[i]
			vals[ord(s[i]) - 48] -= 1 if i == t - 1 else 2
		t -= 1
	if vals[0] == 0 and vals[1] == 0:
		print(''.join(s))
	else:
		print(-1)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = list(input())
	n = len(l)
	if n % 2 and l[n // 2] == '?':
		l[n // 2] = '1' if b % 2 else '0'
	ans = ''
	for i in range(n // 2 + n % 2):
		if l[i] != l[n - 1 - i]:
			if l[i] == '?':
				l[i] = l[n - 1 - i]
			elif l[n - 1 - i] == '?':
				l[n - 1 - i] = l[i]
			else:
				ans = '-1'
				break
		if l[i] == '1':
			b -= 2 if i != n - 1 - i else 1
		elif l[i] == '0':
			a -= 2 if i != n - 1 - i else 1
	if ans:
		print(ans)
		continue
	for i in range(n // 2 + n % 2):
		if l[i] == '?':
			if a:
				l[i] = '0'
				l[n - 1 - i] = '0'
				a -= 2
			elif b:
				l[i] = '1'
				l[n - 1 - i] = '1'
				b -= 2
			else:
				l = ['-1']
				break
	if a == 0 and b == 0:
		print(''.join(l))
	else:
		print(-1)


I = input
for _ in [0] * int(I()):
	((c, a), (d, b)) = sorted(zip('01', map(int, I().split())), key=lambda x: x[1] % 2)
	s = [*I()]
	f = s.count
	i = 0
	for x in s:
		i -= 1
		if '1' < s[i]:
			s[i] = x
	j = f('?')
	i = b - f(d)
	k = -1
	while j > 0:
		k = s.index('?', k + 1)
		s[k] = s[~k] = (d, c)[j > i]
		j -= 2
	print((''.join(s), -1)[(f(c), f(d), s) != (a, b, s[::-1])])


import math
testcases = int(input())
f = []

def apply(h):
	for i in range(len(h)):
		if h[i] != '?' and h[len(h) - 1 - i] == '?':
			h[len(h) - 1 - i] = l[i]

def palidrome(h):
	for i in range(len(h) // 2 + 1):
		if h[len(h) - 1 - i] != l[i]:
			return False
	return True
for j in range(testcases):
	(a, b) = [int(k) for k in input().split()]
	s = input()
	l = ['' for i in range(len(s))]
	for i in range(len(s)):
		l[i] = s[i]
	apply(l)
	count0 = l.count('0')
	count1 = l.count('1')
	for i in range(len(l)):
		if a - count0 > b - count1 and l[i] == '?':
			l[i] = '0'
			count0 += 2
			l[len(l) - 1 - i] = l[i]
		elif l[i] == '?':
			l[i] = '1'
			count1 += 2
			l[len(l) - 1 - i] = l[i]
	if l.count('0') == a and l.count('1') == b and palidrome(l):
		f.append([])
		f[j] = l
	else:
		f.append([])
		f[j] = [-1, '']
for i in range(testcases):
	print(*f[i], sep='')


from os import path
import sys, time
mod = int(1000000000.0 + 7)
from math import ceil, floor, gcd, log, log2, factorial, sqrt
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, permutations
from string import ascii_lowercase, ascii_uppercase
from bisect import *
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
localsys = 0
start_time = time.time()
nCr = lambda n, r: reduce(mul, range(n - r + 1, n + 1), 1) // factorial(r)

def ceill(n, x):
	return (n + x - 1) // x
T = 1

def solve():
	(a, b) = map(int, input().split())
	(s, n) = (list(input().strip()), a + b)
	for i in range(n // 2):
		if s[i] != s[n - i - 1] and s[i] != '?' and (s[n - i - 1] != '?'):
			return print(-1)
		if s[i] == '?':
			s[i] = s[n - i - 1]
		if s[n - i - 1] == '?':
			s[n - i - 1] = s[i]
	a -= s.count('0')
	b -= s.count('1')
	if n % 2 and s[n // 2] == '?':
		if a % 2:
			s[n // 2] = '0'
			a -= 1
		else:
			s[n // 2] = '1'
			b -= 1
	for i in range(n // 2):
		if a >= 2 and s[i] == '?':
			s[i] = s[n - i - 1] = '0'
			a -= 2
		elif b >= 2 and s[i] == '?':
			s[i] = s[n - i - 1] = '1'
			b -= 2
	s = ''.join(s)
	if a == 0 and b == 0 and (s == s[::-1]):
		return print(s)
	return print(-1)

def run():
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
run()
T = I() if T else 1
for _ in range(T):
	solve()
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


for cycle in range(int(input())):
	(zeroes, ones) = [int(x) for x in input().split()]
	s = list(input())
	n = len(s)
	fail = False
	for i in range(n):
		if s[i] != s[n - i - 1]:
			fail |= s[i] != '?' and s[n - i - 1] != '?'
			x = chr(ord(s[i]) + ord(s[n - i - 1]) - ord('?'))
			(s[i], s[n - i - 1]) = (x, x)
	zeroes -= s.count('0')
	ones -= s.count('1')
	for i in range(n):
		if s[i] == '?' and n - i - 1 != i:
			if zeroes >= 2:
				(s[i], s[n - i - 1]) = ('0', '0')
				zeroes -= 2
			else:
				(s[i], s[n - i - 1]) = ('1', '1')
				ones -= 2
	if n % 2 == 1 and s[n // 2] == '?':
		if zeroes >= 1:
			s[n // 2] = '0'
			zeroes -= 1
		else:
			s[n // 2] = '1'
			ones -= 1
	if fail or zeroes != 0 or ones != 0:
		print(-1)
	else:
		print(''.join(s))


for t in range(int(input())):
	(zeros, ones) = map(int, input().split())
	s = list(input())
	counts = {'0': zeros - s.count('0'), '1': ones - s.count('1')}
	left = 0
	right = len(s) - 1
	while left < right:
		if s[left] != s[right]:
			if s[left] == '?':
				s[left] = s[right]
				counts[s[left]] -= 1
			elif s[right] == '?':
				s[right] = s[left]
				counts[s[right]] -= 1
		left += 1
		right -= 1
	left = 0
	right = len(s) - 1
	while left <= right:
		if s[left] == s[right] == '?':
			c = 2 if left != right else 1
			if counts['0'] >= c:
				s[left] = '0'
				s[right] = '0'
				counts['0'] -= c
			elif counts['1'] >= c:
				s[left] = '1'
				s[right] = '1'
				counts['1'] -= c
		left += 1
		right -= 1
	left = 0
	right = len(s) - 1
	impossible = False
	while left < right:
		if s[left] != s[right]:
			impossible = True
			break
		left += 1
		right -= 1
	if any((a < 0 for a in counts.values())) or '?' in s or impossible:
		print('-1')
	else:
		print(''.join(s))


t = int(input())
while t:
	temp = input().split()
	zeros = int(temp[0])
	uns = int(temp[1])
	aux = input()
	palavra = [x for x in aux]
	for x in palavra:
		if x == '0':
			zeros -= 1
		elif x == '1':
			uns -= 1
	tam = len(palavra)
	for i in range(tam // 2):
		if palavra[i] != '?' and palavra[-i - 1] == '?':
			palavra[-i - 1] = palavra[i]
			if palavra[i] == '0':
				zeros -= 1
			else:
				uns -= 1
		elif palavra[i] == '?' and palavra[-i - 1] != '?':
			palavra[i] = palavra[-i - 1]
			if palavra[i] == '0':
				zeros -= 1
			else:
				uns -= 1
	for i in range(tam // 2 + 1):
		if i == tam - i - 1 and palavra[i] == '?':
			if zeros == 1:
				palavra[i] = '0'
				zeros = 0
			elif uns == 1:
				palavra[i] = '1'
				uns = 0
		elif palavra[i] == palavra[-i - 1] == '?':
			if zeros >= 2:
				palavra[i] = '0'
				palavra[-i - 1] = '0'
				zeros -= 2
			else:
				palavra[i] = '1'
				palavra[-i - 1] = '1'
				uns -= 2
	if palavra == palavra[::-1] and zeros == uns == 0:
		print(''.join(palavra))
	else:
		print(-1)
	t -= 1


def main():
	for t in range(int(input())):
		(a, b) = map(int, input().split())
		string = list(input())
		n = a + b
		for i in range(n):
			if string[i] == '?':
				string[i] = string[n - i - 1]
		(a, b) = (a - string.count('0'), b - string.count('1'))
		for i in range(n // 2 + 1):
			if string[i] == '?' and i != n - i - 1:
				if a > 1:
					string[i] = string[n - i - 1] = '0'
					a -= 2
				elif b > 1:
					string[i] = string[n - i - 1] = '1'
					b -= 2
			elif string[i] == '?':
				if a > 0:
					string[i] = '0'
					a -= 1
				elif b > 0:
					string[i] = '1'
					b -= 1
		if string == string[::-1] and a == b == 0:
			print(''.join(string))
		else:
			print(-1)
main()


import math
import bisect
import copy
from collections import defaultdict
from collections import OrderedDict
from sys import stdout
import sys
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input())
	n = a + b
	for i in s:
		if i == '0':
			a -= 1
		elif i == '1':
			b -= 1
	for i in range(n // 2):
		if s[i] == '?' and s[n - 1 - i] == '0':
			s[i] = '0'
			a -= 1
		elif s[i] == '0' and s[n - 1 - i] == '?':
			s[n - 1 - i] = '0'
			a -= 1
		elif s[i] == '1' and s[n - 1 - i] == '?':
			s[n - 1 - i] = '1'
			b -= 1
		elif s[i] == '?' and s[n - 1 - i] == '1':
			s[i] = '1'
			b -= 1
	if n % 2 == 1:
		if a % 2 == 1 and s[n // 2] == '?':
			s[n // 2] = '0'
			a -= 1
		elif b % 2 == 1 and s[n // 2] == '?':
			s[n // 2] = '1'
			b -= 1
	for i in range(n // 2):
		if s[i] == '?' and s[n - 1 - i] == '?':
			if a >= 2:
				(s[i], s[n - 1 - i]) = ('0', '0')
				a -= 2
			elif b >= 2:
				(s[i], s[n - 1 - i]) = ('1', '1')
				b -= 2
	if s == s[::-1] and a == b == 0:
		print(''.join(s))
	else:
		print(-1)


import sys
import os.path
from collections import *
import math
import bisect
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
tt = int(input())
while tt:
	tt -= 1
	(a, b) = [int(x) for x in input().split()]
	s = list(input().rstrip('\n'))
	res = 1
	n = len(s)
	for i in range(n):
		if s[i] != '?' and s[i] != s[n - i - 1]:
			if s[n - i - 1] != '?':
				res = -1
				break
			else:
				s[n - i - 1] = s[i]
	if res == -1:
		print(-1)
		continue
	h = Counter(s)
	a -= h['0']
	b -= h['1']
	if a < 0 or b < 0 or (a % 2 and b % 2) or (a + b != h['?']):
		print(-1)
	else:
		if a % 2 == 0:
			for i in range(n):
				if a:
					if s[i] == '?' and i != n - i - 1:
						s[i] = '0'
						s[n - i - 1] = '0'
						a -= 2
			for i in range(n):
				if s[i] == '?':
					s[i] = '1'
		elif b % 2 == 0:
			for i in range(n):
				if b:
					if s[i] == '?' and i != n - i - 1:
						s[i] = '1'
						s[n - i - 1] = '1'
						b -= 2
			for i in range(n):
				if s[i] == '?':
					s[i] = '0'
		print(''.join(s))


t = int(input())
while t > 0:
	(a, b) = map(int, input().split(' '))
	s = list(input())
	n = len(s)
	flag = True
	for i in range(0, n // 2 + n % 2):
		if s[i] != '?' and s[n - i - 1] != '?':
			if s[i] != s[n - i - 1]:
				flag = False
				break
			elif s[i] == '0':
				if i != n - i - 1:
					a -= 2
				else:
					a -= 1
			elif i != n - i - 1:
				b -= 2
			else:
				b -= 1
		elif s[i] != '?' and s[n - i - 1] == '?':
			if s[i] == '0':
				if a <= 0:
					flag = False
					break
				else:
					s[n - i - 1] = '0'
					a -= 2
			elif b <= 0:
				flag = False
				break
			else:
				s[n - i - 1] = '1'
				b -= 2
		elif s[i] == '?' and s[n - i - 1] != '?':
			if s[n - i - 1] == '0':
				if a <= 0:
					flag = False
					break
				else:
					s[i] = '0'
					a -= 2
			elif b <= 0:
				flag = False
				break
			else:
				s[i] = '1'
				b -= 2
	for i in range(0, n // 2 + n % 2):
		if s[i] == '?':
			if a > b:
				s[i] = '0'
				a -= 1
				if i != n - i - 1:
					s[n - i - 1] = '0'
					a -= 1
			else:
				s[i] = '1'
				b -= 1
				if i != n - i - 1:
					s[n - i - 1] = '1'
					b -= 1
	if a != 0 or b != 0:
		flag = False
	if flag:
		print(''.join(s))
	else:
		print(-1)
	t -= 1


for _ in range(int(input())):
	(a, b) = (int(x) for x in input().split())
	s = input()
	k = []
	for i in range(a + b):
		k.append(s[i])
	l = a + b
	if a % 2 == 1 and b % 2 == 1:
		print(-1)
		continue
	elif a % 2 == 1:
		if s[l // 2] == '1':
			print(-1)
			continue
		else:
			k[l // 2] = '0'
	elif b % 2 == 1:
		if s[l // 2] == '0':
			print(-1)
			continue
		else:
			k[l // 2] = '1'
	m = 0
	n = 0
	come = 0
	for i in range(l // 2):
		if k[i] != k[n - 1 - i]:
			if k[i] == '?':
				k[i] = k[n - 1 - i]
			elif k[n - 1 - i] == '?':
				k[n - 1 - i] = k[i]
			else:
				come = 1
	if come == 1:
		print(-1)
		continue
	if k.count('1') > b:
		come = 1
	if k.count('0') > a:
		come = 1
	if come == 1:
		print(-1)
		continue
	a -= k.count('0')
	b -= k.count('1')
	for i in range(l // 2):
		if k[i] == '?':
			if a != 0:
				a -= 2
				k[i] = '0'
				k[n - 1 - i] = '0'
			else:
				b -= 2
				k[i] = '1'
				k[n - 1 - i] = '1'
	s = ''.join(k)
	print(s)


def result(s, a, b):
	x = [a, b]
	for i in range(0, len(s)):
		if s[i] == '?' and s[-i - 1] == '?':
			pass
		elif s[i] == '?':
			s[i] = s[-i - 1]
			x[int(s[i])] -= 1
		elif s[-i - 1] == '?':
			s[-i - 1] = s[i]
			x[int(s[i])] -= 1
		elif s[i] != s[-1 - i]:
			return '-1'
		else:
			x[int(s[i])] -= 1
	if (a + b) % 2 == 1:
		if s[len(s) // 2] == '?':
			if x[0] % 2 == 1:
				s[len(s) // 2] = '0'
				x[0] -= 1
			else:
				s[len(s) // 2] = '1'
				x[1] -= 1
	if x[0] < 0 or x[1] < 0 or x[0] % 2 == 1:
		return '-1'
	for i in range(0, len(s)):
		if s[i] == '?':
			if x[0] > 0:
				s[i] = '0'
				s[-i - 1] = '0'
				x[0] -= 2
			else:
				s[i] = '1'
				s[-i - 1] = '1'
				x[1] -= 2
	return ''.join(s)
for i in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input())
	print(result(s, a, b))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = [i for i in input()]
	n = len(s)
	a -= s.count('0')
	b -= s.count('1')
	ok = True
	for i in range(n >> 1):
		if s[i] == '1':
			if s[n - i - 1] == '?':
				s[n - i - 1] = '1'
				b -= 1
			elif s[n - i - 1] == '0':
				ok = False
				break
		elif s[i] == '0':
			if s[n - i - 1] == '?':
				s[n - i - 1] = '0'
				a -= 1
			elif s[n - i - 1] == '1':
				ok = False
				break
		elif s[n - i - 1] == '0':
			s[i] = '0'
			a -= 1
		elif s[n - i - 1] == '1':
			s[i] = '1'
			b -= 1
	if ok:
		for i in range(n >> 1):
			if s[i] == '?':
				if a >= b:
					s[i] = '0'
					s[n - i - 1] = '0'
					a -= 2
				else:
					s[i] = '1'
					s[n - i - 1] = '1'
					b -= 2
		if n & 1:
			if s[n >> 1] == '?':
				if a:
					s[n >> 1] = '0'
					a -= 1
				else:
					s[n >> 1] = '1'
					b -= 1
		if a == 0 and b == 0:
			print(''.join(s))
		else:
			print(-1)
	else:
		print(-1)


for _ in range(int(input())):
	(z, o) = map(int, input().split())
	s = list(input())
	n = len(s)
	(i, j) = (0, n)
	while i < j:
		if s[i] == s[j - 1] == '?':
			pass
		elif s[i] == '?':
			if s[j - 1] == '0':
				s[i] = '0'
				z -= 2
			else:
				s[i] = '1'
				o -= 2
		elif s[j - 1] == '?':
			if s[i] == '0':
				s[j - 1] = '0'
				z -= 2
			else:
				s[j - 1] = '1'
				o -= 2
		else:
			if s[i] != s[j - 1]:
				print(-1)
				break
			if s[i] == '0':
				z -= 2 if i + 1 < j else 1
			else:
				o -= 2 if i + 1 < j else 1
		if z < 0 or o < 0:
			print(-1)
			break
		i += 1
		j -= 1
	else:
		(i, j) = (0, n)
		while i + 1 < j:
			if s[i] == '?':
				if z >= 2:
					s[i] = s[j - 1] = '0'
					z -= 2
				elif o >= 2:
					s[i] = s[j - 1] = '1'
					o -= 2
				else:
					print(-1)
					break
			i += 1
			j -= 1
		else:
			if s[n // 2] == '?':
				if z + o != 1:
					print(-1)
				else:
					s[n // 2] = '0' if z else '1'
					print(''.join(s))
			else:
				print(''.join(s))


from sys import stdin
from collections import defaultdict
input = stdin.readline
for _ in range(int(input())):
	(b, a) = map(int, input().split())
	arr = list(input().strip())
	n = len(arr)
	aa = a
	bb = b
	l = []
	for i in range(n // 2):
		if arr[i] != '?' and arr[n - i - 1] != '?':
			pass
		elif arr[i] != '?':
			arr[n - i - 1] = arr[i]
		elif arr[n - i - 1] != '?':
			arr[i] = arr[n - i - 1]
		else:
			l.append([i, n - i - 1])
		if arr[i] == '1':
			a -= 1
		elif arr[i] == '0':
			b -= 1
		if arr[n - i - 1] == '1':
			a -= 1
		elif arr[n - i - 1] == '0':
			b -= 1
	if n % 2 == 1:
		if arr[n // 2] == '1':
			a -= 1
		elif arr[n // 2] == '0':
			b -= 1
	ff = len(l) * 2
	i = 0
	while a > 1 or b > 1:
		if ff < 2:
			break
		if a > 1:
			arr[l[i][0]] = '1'
			arr[l[i][1]] = '1'
			a -= 2
		elif b > 1:
			arr[l[i][0]] = '0'
			arr[l[i][1]] = '0'
			b -= 2
		i += 1
		ff -= 2
	if n % 2 == 1:
		if arr[n // 2] == '?':
			if a > 0:
				arr[n // 2] = '1'
			else:
				arr[n // 2] = '0'
	s1 = 0
	s2 = 0
	s3 = 0
	f = 0
	for i in range(n):
		if arr[i] != arr[n - i - 1]:
			f = 1
		if arr[i] == '1':
			s1 += 1
		elif arr[i] == '0':
			s2 += 1
		else:
			s3 += 1
	if s1 != aa or s2 != bb or s3 > 0 or f:
		print(-1)
		continue
	print(''.join(arr))


list_ans = []
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = input()
	listx = [x for x in s]
	n = len(s)
	list1 = []
	a -= s.count('0')
	b -= s.count('1')
	for i in range(n // 2):
		if s[i] == '?':
			if s[n - i - 1] == '1':
				b -= 1
				listx[i] = '1'
			elif s[n - i - 1] == '0':
				a -= 1
				listx[i] = '0'
			else:
				list1.append(i)
		elif s[n - i - 1] == '?':
			listx[n - i - 1] = s[i]
			if s[i] == '1':
				b -= 1
			else:
				a -= 1
	for x in list1:
		if a >= 2:
			listx[x] = '0'
			listx[n - x - 1] = '0'
			a -= 2
		elif b >= 2:
			listx[x] = '1'
			listx[n - x - 1] = '1'
			b -= 2
	if a == 1:
		listx[n // 2] = '0'
		a -= 1
	elif b == 1:
		listx[n // 2] = '1'
		b -= 1
	if a == 0 and b == 0 and (listx == list(reversed(listx))):
		list_ans.append(''.join(listx))
	else:
		list_ans.append(-1)
print(*list_ans, sep='\n')


for _ in range(int(input())):
	(z, o) = list(map(int, input().split()))
	l = list(input())
	n = len(l)
	for i in l:
		if i == '1':
			o -= 1
		elif i == '0':
			z -= 1
	if z < 0 or o < 0:
		print(-1)
	else:
		for i in range(n // 2):
			if l[i] != l[n - 1 - i]:
				if l[i] == '?' or l[n - i - 1] == '?':
					if l[i] == '1':
						o -= 1
						l[n - i - 1] = '1'
					elif l[n - i - 1] == '1':
						o -= 1
						l[i] = '1'
					elif l[i] == '0':
						z -= 1
						l[n - i - 1] = '0'
					elif l[n - 1 - i] == '0':
						z -= 1
						l[i] = '0'
				else:
					print(-1)
					break
		else:
			if z < 0 or o < 0:
				print(-1)
			else:
				for i in range(n // 2):
					if l[i] == l[n - 1 - i] and l[i] == '?':
						if z >= 2:
							l[i] = l[n - i - 1] = '0'
							z -= 2
						elif o >= 2:
							l[i] = l[n - i - 1] = '1'
							o -= 2
				if n % 2 == 1:
					if l[n // 2] == '?' and z > 0:
						z -= 1
						l[n // 2] = '0'
					elif l[n // 2] == '?' and o > 0:
						o -= 1
						l[n // 2] = '1'
				if z + o == 0 and '?' not in l:
					print(*l, sep='')
				else:
					print(-1)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input())
	a -= s.count('0')
	b -= s.count('1')
	n = len(s)
	flag = True
	for i in range(n // 2 + 1):
		if s[i] != '?' and s[n - i - 1] == '?':
			if s[i] == '0':
				s[n - i - 1] = '0'
				a -= 1
			else:
				s[n - i - 1] = '1'
				b -= 1
		elif s[i] == '?' and s[n - i - 1] != '?':
			if s[n - i - 1] == '0':
				s[i] = '0'
				a -= 1
			else:
				s[i] = '1'
				b -= 1
		elif s[i] != s[n - i - 1]:
			flag = False
			break
	q = s.count('?')
	if flag == False or a + b != q:
		print(-1)
		continue
	for i in range(n // 2):
		if s[i] == '?' and s[n - i - 1] == '?':
			if a >= 2:
				s[i] = '0'
				s[n - i - 1] = '0'
				a -= 2
			elif b >= 2:
				s[i] = '1'
				s[n - i - 1] = '1'
				b -= 2
			else:
				flag = False
				break
	if n % 2 == 1:
		mid = n // 2
		if s[mid] == '?':
			if a >= 1:
				s[mid] = '0'
				a -= 1
			elif b >= 1:
				s[mid] = '1'
				b -= 1
			else:
				flag = True
	if flag == False or a != 0 or b != 0:
		print(-1)
		continue
	print(''.join(s))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(str(input()))
	n = len(s)
	for i in s:
		if i == '0':
			a -= 1
		if i == '1':
			b -= 1
	for i in range(len(s) // 2):
		if s[i] == '0' and s[n - 1 - i] == '?':
			s[n - 1 - i] = '0'
			a -= 1
		if s[i] == '1' and s[n - 1 - i] == '?':
			s[n - 1 - i] = '1'
			b -= 1
		if s[i] == '?' and s[n - 1 - i] == '0':
			s[i] = '0'
			a -= 1
		if s[i] == '?' and s[n - 1 - i] == '1':
			s[i] = '1'
			b -= 1
	if len(s) % 2 != 0 and s[n // 2] == '?':
		if a % 2 == 0:
			s[n // 2] = '1'
			b -= 1
		else:
			s[n // 2] = '0'
			a -= 1
	for i in range(len(s) // 2):
		if s[i] == '?' and s[n - i - 1] == '?':
			if a >= 2:
				s[i] = '0'
				s[n - i - 1] = '0'
				a -= 2
			elif b >= 2:
				s[i] = '1'
				s[n - i - 1] = '1'
				b -= 2
	if a < 0 or b < 0 or s != s[::-1] or ('?' in s):
		print(-1)
	else:
		ans = ''
		print(ans.join(s))


for testcase in range(int(input())):
	arr = [int(x) for x in input().split()]
	(x, y) = (arr[0], arr[1])
	s = list(input())
	(i, j) = (0, len(s) - 1)
	while i <= j:
		if i == j and s[i] != '?':
			if s[i] == '0':
				x -= 1
			else:
				y -= 1
		elif s[i] == s[j] and s[i] != '?':
			if s[i] == '0':
				x -= 2
			else:
				y -= 2
		elif s[i] == '0' and s[j] == '?':
			x -= 2
			s[j] = '0'
		elif s[i] == '1' and s[j] == '?':
			y -= 2
			s[j] = '1'
		elif s[j] == '0' and s[i] == '?':
			x -= 2
			s[i] = '0'
		elif s[j] == '1' and s[i] == '?':
			y -= 2
			s[i] = '1'
		i += 1
		j -= 1
		if x < 0 or y < 0:
			print(-1)
			break
	else:
		(i, j) = (0, len(s) - 1)
		while i <= j:
			if i == j:
				if s[i] == '?':
					if x == 1 and y == 0:
						x -= 1
						s[i] = '0'
					elif y == 1 and x == 0:
						y -= 1
						s[i] = '1'
					else:
						print(-1)
						break
			elif s[i] == s[j] and s[i] == '?':
				if x > 1:
					x -= 2
					s[i] = '0'
					s[j] = '0'
				elif y > 1:
					y -= 2
					s[i] = '1'
					s[j] = '1'
				else:
					print(-1)
					break
			i += 1
			j -= 1
			if x < 0 or y < 0:
				print(-1)
				break
		else:
			if x == 0 and y == 0:
				print(''.join(s))
			else:
				print(-1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = [i for i in input()[:-1]]
	n = a + b
	for i in range(n):
		if s[i] == '?':
			s[i] = s[n - i - 1]
	a -= s.count('0')
	b -= s.count('1')
	i = 0
	j = n - 1
	while i <= j:
		if i != j and s[i] == '?':
			if a > 1:
				s[i] = s[n - 1 - i] = '0'
				a -= 2
			elif b > 1:
				s[i] = s[n - 1 - i] = '1'
				b -= 2
		elif s[i] == '?':
			if a > 0:
				s[i] = '0'
				a -= 1
			elif b > 0:
				s[i] = '1'
				b -= 1
		i += 1
		j -= 1
	s = ''.join(s)
	if s == s[::-1] and a == b == 0:
		print(s)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	(a1, b1) = map(int, input().split())
	S1 = input()
	S = []
	answer = 0
	for h in S1:
		S.append(h)
	n = len(S) - 1
	for i in range(len(S) // 2):
		if S[i] != '?' and S[n - i] != '?':
			if S[i] != S[n - i]:
				answer = -1
				break
		elif S[i] == '?' and S[n - i] != '?':
			S[i] = S[n - i]
		elif S[i] != '?' and S[n - i] == '?':
			S[n - i] = S[i]
	a = S.count('0')
	b = S.count('1')
	if answer != -1:
		for i in range(len(S) // 2):
			if S[n - i] == '?' and S[i] == '?':
				if a + 2 <= a1:
					S[i] = '0'
					S[n - i] = '0'
					a += 2
				else:
					S[i] = '1'
					S[n - i] = '1'
					b += 2
			if a > a1 or b > b1:
				answer = -1
				break
	if len(S) % 2 != 0:
		if S[len(S) // 2] == '?':
			if a < a1:
				a += 1
				S[len(S) // 2] = '0'
			else:
				b += 1
				S[len(S) // 2] = '1'
	if answer == -1:
		print(-1)
	elif a1 != a or b1 != b:
		print(-1)
	else:
		StrS = ''.join(S)
		print(StrS)


def main():
	t = int(input())
	allans = []
	for _ in range(t):
		(a, b) = readIntArr()
		n = a + b
		arr = list(input())
		possible = True
		l = 0
		r = n - 1
		while l <= r:
			if l == r:
				if arr[l] == '0':
					a -= 1
				elif arr[r] == '1':
					b -= 1
				else:
					pass
			elif arr[l] != '?' and arr[r] != '?':
				if arr[l] != arr[r]:
					possible = False
					break
				elif arr[l] == '0':
					a -= 2
				else:
					b -= 2
			elif arr[l] == '?' and arr[r] == '?':
				pass
			elif arr[l] == '?':
				arr[l] = arr[r]
				if arr[r] == '0':
					a -= 2
				else:
					b -= 2
			elif arr[r] == '?':
				arr[r] = arr[l]
				if arr[l] == '0':
					a -= 2
				else:
					b -= 2
			else:
				assert False
			l += 1
			r -= 1
		l = 0
		r = n - 1
		while l <= r:
			if l == r:
				if arr[l] == '?':
					if a > 0:
						arr[l] = '0'
						a -= 1
					else:
						arr[l] = '1'
						b -= 1
			elif arr[l] == '?' and arr[r] == '?':
				if a > 1:
					arr[l] = '0'
					arr[r] = '0'
					a -= 2
				else:
					arr[l] = '1'
					arr[r] = '1'
					b -= 2
			l += 1
			r -= 1
		if not (a == 0 and b == 0):
			possible = False
		if possible:
			allans.append(''.join(arr))
		else:
			allans.append(-1)
	multiLineArrayPrint(allans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultVal, dimensionArr):
	dv = defaultVal
	da = dimensionArr
	if len(da) == 1:
		return [dv for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(x, y):
	print('? {} {}'.format(x, y))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(ans))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


import sys, math, itertools, random, bisect
from collections import defaultdict
INF = 10 ** 18

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7

def check(s, n, flag, zero, one, a, b):
	for i in range(n // 2):
		if s[i] != '?' and s[n - i - 1] != '?':
			if s[i] != s[n - i - 1]:
				flag = False
				break
		elif s[i] != '?' or s[n - i - 1] != '?':
			if s[i] == '?':
				s[i] = s[n - i - 1]
				if s[n - i - 1] == '0':
					zero += 1
				else:
					one += 1
			else:
				s[n - i - 1] = s[i]
				if s[i] == '0':
					zero += 1
				else:
					one += 1
for _ in range(int(input())):
	(a, b) = get_ints()
	s = list(input())
	n = len(s)
	if n == 0:
		if a or b:
			print(-1)
		else:
			print('')
		continue
	zero = s.count('0')
	one = s.count('1')
	flag = True
	if n % 2 == 0:
		if a & 1 or b & 1:
			print(-1)
		else:
			for i in range(n // 2):
				if s[i] != '?' and s[n - i - 1] != '?':
					if s[i] != s[n - i - 1]:
						flag = False
						break
				elif s[i] != '?' or s[n - i - 1] != '?':
					if s[i] == '?':
						s[i] = s[n - i - 1]
						if s[n - i - 1] == '0':
							zero += 1
						else:
							one += 1
					else:
						s[n - i - 1] = s[i]
						if s[i] == '0':
							zero += 1
						else:
							one += 1
			if not flag:
				print(-1)
			else:
				for i in range(n // 2):
					if s[i] == '?':
						if zero != a:
							s[i] = '0'
							s[n - i - 1] = '0'
							zero += 2
						else:
							s[i] = '1'
							s[n - i - 1] = '1'
							one += 2
				if s.count('0') != a or s.count('1') != b or s != s[::-1]:
					print(-1)
				else:
					print(''.join(s))
	else:
		if a & 1:
			x = '0'
		else:
			x = '1'
		if s[n // 2] == '?':
			s[n // 2] = x
			if x == '0':
				zero += 1
			else:
				one += 1
		elif s[n // 2] != x:
			flag = False
		if not flag:
			print(-1)
		else:
			for i in range(n // 2):
				if s[i] != '?' and s[n - i - 1] != '?':
					if s[i] != s[n - i - 1]:
						flag = False
						break
				elif s[i] != '?' or s[n - i - 1] != '?':
					if s[i] == '?':
						s[i] = s[n - i - 1]
						if s[n - i - 1] == '0':
							zero += 1
						else:
							one += 1
					else:
						s[n - i - 1] = s[i]
						if s[i] == '0':
							zero += 1
						else:
							one += 1
			if not flag:
				print(-1)
			else:
				for i in range(n // 2):
					if s[i] == '?':
						if zero != a:
							s[i] = '0'
							s[n - i - 1] = '0'
							zero += 2
						else:
							s[i] = '1'
							s[n - i - 1] = '1'
							one += 2
				if s.count('0') != a or s.count('1') != b or s != s[::-1]:
					print(-1)
				else:
					print(''.join(s))


import sys, os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
try:
	sys.stdin = open('./input.txt', 'r')
	sys.stdout = open('./output.txt', 'w')
except:
	pass
from collections import Counter
from math import sqrt, factorial, gcd

def input():
	return sys.stdin.readline().strip()

def map_input(dtype=int):
	return map(dtype, sys.stdin.readline().split())

def list_input(dtype=int):
	return list(map(dtype, sys.stdin.readline().split()))
INF = float('inf')
_INF = float('-inf')

def solve(a, b, s):
	if not s or len(s) != a + b:
		print('-1')
		return
	tr = Counter(s)
	tr['0'] = a - tr['0']
	tr['1'] = b - tr['1']
	N = len(s) // 2
	fh = s[:N]
	sh = s[-N:][::-1]
	mid = s[N] if len(s) % 2 != 0 and len(s) > 1 else ''
	if len(s) == 1:
		mid = s[0]
		fh = sh = []
	for i in range(len(fh)):
		if fh[i] != sh[i]:
			if fh[i] == '?' and sh[i] != '?':
				fh[i] = sh[i]
				tr[sh[i]] -= 1
			elif sh[i] == '?' and fh[i] != '?':
				sh[i] = fh[i]
				tr[fh[i]] -= 1
		if fh[i] != sh[i]:
			print('-1')
			return
	for i in range(len(fh)):
		if fh[i] == '?' and sh[i] == '?':
			if tr['0'] >= 2:
				fh[i] = sh[i] = '0'
				tr['0'] -= 2
			elif tr['1'] >= 2:
				fh[i] = sh[i] = '1'
				tr['1'] -= 2
			else:
				print('-1')
				return
		if fh[i] != sh[i]:
			print('-1')
			return
	if mid not in ['0', '1', '']:
		if tr['0'] >= 1:
			mid = '0'
			tr['0'] -= 1
		elif tr['1'] >= 1:
			mid = '1'
			tr['1'] -= 1
	if tr['0'] < 0 or tr['1'] < 0:
		print('-1')
		return
	print(''.join(fh) + mid + ''.join(sh[::-1]))
for tc in range(1, int(input()) + 1):
	(a, b) = map_input()
	s = list(input())
	solve(a, b, s)


from math import *
from collections import defaultdict as dt
from sys import stdin
inp = lambda : stdin.readline().strip()
I = lambda : int(inp())
M = lambda : map(int, stdin.readline().split())
L = lambda : list(map(int, stdin.readline().split()))
mod = 1000000009
inf = 100000000000000000000
ss = 'abcdefghijklmnopqrstuvwxyz'

def solve():
	(x, y) = M()
	a = list(input())
	(e, f) = ([], [])
	(c, d) = (0, 0)
	for i in range(len(a) // 2):
		if a[i] == a[-i - 1]:
			if a[i] == '0':
				c = c + 2
			elif a[i] == '1':
				d = d + 2
			else:
				e.append(i)
				f.append(-i - 1)
		elif a[i] == '0' and a[-i - 1] == '?':
			a[-i - 1] = '0'
			c = c + 2
		elif a[i] == '?' and a[-i - 1] == '0':
			a[i] = '0'
			c = c + 2
		elif a[i] == '1' and a[-i - 1] == '?':
			a[-i - 1] = '1'
			d = d + 2
		elif a[i] == '?' and a[-i - 1] == '1':
			a[i] = '1'
			d = d + 2
		else:
			print(-1)
			return
	x = x - c
	y = y - d
	for i in range(len(e)):
		if x > y:
			a[e[i]] = '0'
			a[f[i]] = '0'
			x = x - 2
		else:
			a[e[i]] = '1'
			a[f[i]] = '1'
			y = y - 2
	if len(a) % 2 == 1:
		z = a[len(a) // 2]
		if z == '?':
			if x == 1:
				a[len(a) // 2] = '0'
				x = x - 1
			elif y == 1:
				a[len(a) // 2] = '1'
				y = y - 1
			else:
				print(-1)
				return
		elif z == '0':
			x = x - 1
		else:
			y = y - 1
	if x == y == 0:
		print(''.join(a))
	else:
		print(-1)
tt = 1
tt = I()
for _ in range(tt):
	solve()


for t in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input())
	if a % 2 == 1 and b % 2 == 1:
		print(-1)
		continue
	len_s = a + b
	for i in range(len_s):
		if s[i] == '?':
			s[i] = s[len_s - i - 1]
	a -= s.count('0')
	b -= s.count('1')
	for i in range(len_s // 2):
		if s[i] == '?':
			if a >= b:
				s[i] = s[len_s - i - 1] = '0'
				a -= 2
			else:
				s[i] = s[len_s - i - 1] = '1'
				b -= 2
	if len_s % 2 == 1:
		if s[len_s // 2] == '?':
			if a > 0:
				s[len_s // 2] = '0'
				a -= 1
			elif b > 0:
				s[len_s // 2] = '1'
				b -= 1
	s = ''.join(s)
	if s != s[::-1] or a < 0 or b < 0:
		print(-1)
	else:
		print(s)


from math import ceil
for i in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input().strip())
	n = len(s)
	a -= s.count('0')
	b -= s.count('1')
	for j in range(n // 2):
		if s[j] != s[n - 1 - j]:
			if s[j] == '?':
				if s[n - 1 - j] == '0':
					if a > 0:
						a -= 1
						s[j] = '0'
				elif b > 0:
					b -= 1
					s[j] = '1'
			elif s[n - 1 - j] == '?':
				if s[j] == '0':
					if a > 0:
						a -= 1
						s[n - 1 - j] = '0'
				elif b > 0:
					b -= 1
					s[n - 1 - j] = '1'
	for j in range(n // 2):
		if s[j] == s[n - 1 - j] == '?':
			if a >= 2:
				a -= 2
				s[j] = '0'
				s[n - 1 - j] = '0'
			elif b >= 2:
				b -= 2
				s[j] = '1'
				s[n - 1 - j] = '1'
	if n % 2 == 1 and s[n // 2] == '?':
		if a > 0:
			a -= 1
			s[n // 2] = '0'
		elif b > 0:
			b -= 1
			s[n // 2] = '1'
	an = 1
	for j in range(ceil(n / 2)):
		if s[j] != s[n - 1 - j] or s[j] == '?' or s[n - 1 - j] == '?':
			an = -1
			break
	if an == -1 or a > 0 or b > 0:
		print(-1)
	else:
		print(''.join(s))


import math

def solve(s, n, a, b):
	s = list(s)
	for i in s:
		if i == '0':
			a -= 1
		elif i == '1':
			b -= 1
	for i in range(n // 2):
		if s[i] == '?' and s[-i - 1] != '?':
			s[i] = s[-i - 1]
			if s[i] == '0':
				a -= 1
			else:
				b -= 1
		elif s[i] != '?' and s[-i - 1] == '?':
			s[-i - 1] = s[i]
			if s[i] == '0':
				a -= 1
			else:
				b -= 1
	for i in range(n // 2):
		if s[i] == s[-i - 1] == '?':
			if a >= b:
				s[i] = '0'
				s[-i - 1] = '0'
				a -= 2
			else:
				s[i] = '1'
				s[-i - 1] = '1'
				b -= 2
	if n % 2 != 0 and s[n // 2] == '?':
		if a >= b:
			s[n // 2] = '0'
			a -= 1
		else:
			s[n // 2] = '1'
			b -= 1
	for i in range(n // 2):
		if s[i] != s[-i - 1]:
			return -1
	if a != b != 0:
		return -1
	return ''.join(s)
t = int(input())
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	s = input()
	print(solve(s, a + b, a, b))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = a + b
	s1 = list(input())
	for i in range(c):
		if s1[i] == '?':
			s1[i] = s1[c - i - 1]
	a -= s1.count('0')
	b -= s1.count('1')
	for i in range(c // 2 + 1):
		if i != c - i - 1 and s1[i] == '?':
			if a > 1:
				s1[i] = s1[c - i - 1] = '0'
				a -= 2
			elif b > 1:
				s1[i] = s1[c - i - 1] = '1'
				b -= 2
		elif s1[i] == '?':
			if a > 0:
				s1[i] = '0'
				a -= 1
			elif b > 0:
				s1[i] = '1'
				b -= 1
	s1 = ''.join(s1)
	if s1 == s1[::-1] and a == b == 0:
		print(s1)
	else:
		print(-1)


def solve():
	(a, b) = map(int, input().split())
	s = list(input())
	n = a + b
	for i in s:
		if i == '0':
			a -= 1
		elif i == '1':
			b -= 1
	for i in range(n // 2):
		if s[i] != '?' and s[n - i - 1] != '?' and (s[i] != s[n - i - 1]):
			return -1
		elif s[i] == '?' and s[n - i - 1] != '?':
			if s[n - i - 1] == '0':
				a -= 1
				s[i] = '0'
			else:
				b -= 1
				s[i] = '1'
		elif s[n - i - 1] == '?' and s[i] != '?':
			if s[i] == '0':
				a -= 1
				s[n - i - 1] = '0'
			else:
				b -= 1
				s[n - i - 1] = '1'
	for i in range(n // 2):
		if s[i] == '?':
			if a >= 2:
				s[i] = s[n - i - 1] = '0'
				a -= 2
			else:
				s[i] = s[n - i - 1] = '1'
				b -= 2
	if n & 1 == 1 and s[n // 2] == '?':
		if a > 0:
			s[n // 2] = '0'
			a -= 1
		else:
			s[n // 2] = '1'
			b -= 1
	if a != 0 or b != 0:
		return -1
	return ''.join(s)
for _ in range(int(input())):
	print(solve())


t = int(input())
for k in range(t):
	(z, e) = map(int, input().split())
	s = list(input())
	nz = s.count('0')
	ne = s.count('1')
	flag = True
	for i in range(len(s)):
		if s[i] != '?' and s[i] != s[len(s) - i - 1] and (s[len(s) - i - 1] != '?'):
			flag = False
			break
		if s[i] == '?':
			s[i] = s[len(s) - i - 1]
	(nz, ne) = (s.count('0'), s.count('1'))
	if nz > z or ne > e:
		flag = False
	if not flag:
		print(-1)
		continue
	for i in range(len(s) // 2):
		if s[i] == '?' and s[len(s) - i - 1] == '?':
			if z - nz >= 2:
				(s[i], s[len(s) - i - 1]) = ('0', '0')
				nz += 2
			elif e - ne >= 2:
				(s[i], s[len(s) - i - 1]) = ('1', '1')
				ne += 2
			else:
				flag = False
				break
	if not flag:
		print(-1)
		continue
	if len(s) % 2 == 1 and s[len(s) // 2] == '?':
		if ne < e:
			s[len(s) // 2] = '1'
		elif nz < z:
			s[len(s) // 2] = '0'
		else:
			flag = False
	for i in range(len(s)):
		if s[i] == '?' and s[len(s) - i - 1] != '?':
			s[i] = s[len(s) - i - 1]
	(nz, ne) = (s.count('0'), s.count('1'))
	if nz == z and ne == e and flag:
		print(*s, sep='')
	else:
		print(-1)


for _ in range(int(input())):
	flag = True
	(a, b) = map(int, input().split())
	s = [i for i in input()]
	for i in range(a + b):
		if s[i] == '?':
			ch = s[-i - 1]
			if ch != '?':
				s[i] = ch
	a -= s.count('0')
	b -= s.count('1')
	if a < 0 or b < 0:
		flag = False
	n = a + b
	if n % 2 == 0:
		if a % 2 == 1:
			flag = False
	if flag:
		if n % 2 == 0:
			new = [0 for i in range(a // 2)] + [1 for i in range(b)] + [0 for i in range(a // 2)]
		elif a % 2 == 0:
			new = [0 for i in range(a // 2)] + [1 for i in range(b)] + [0 for i in range(a // 2)]
		else:
			new = [1 for i in range(b // 2)] + [0 for i in range(a)] + [1 for i in range(b // 2)]
		if new:
			for i in range(len(s)):
				if s[i] == '?':
					s[i] = new.pop()
		if s != s[::-1]:
			print(-1)
		else:
			print(''.join((str(i) for i in s)))
	else:
		print(-1)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	s = input()
	s = list(s)
	z = 0
	o = 0
	for j in range(a + b):
		if s[j] == '1':
			o = o + 1
		elif s[j] == '0':
			z = z + 1
	z = a - z
	o = b - o
	c = 1
	n = a + b
	for j in range(a + b):
		if s[j] == '?' and s[n - j - 1] == '0':
			if z <= 0:
				c = 0
				break
			s[j] = s[n - j - 1]
			z = z - 1
		elif s[j] == '?' and s[n - j - 1] == '1':
			if o <= 0:
				c = 0
				break
			s[j] = s[n - j - 1]
			o = o - 1
	for j in range(a + b):
		if s[j] == '?' and s[n - j - 1] == '?':
			if z > 0 and z >= o:
				s[j] = '0'
				s[n - j - 1] = '0'
				if j == n - j - 1:
					z = z - 1
				else:
					z = z - 2
			elif o > 0 and o >= z:
				s[j] = '1'
				s[n - j - 1] = '1'
				if j == n - j - 1:
					o = o - 1
				else:
					o = o - 2
			else:
				c = 0
				break
	s = ''.join(s)
	if s == s[::-1] and c == 1 and (o == 0) and (z == 0):
		print(s)
	else:
		print(-1)


x = int(input())
for i in range(x):
	(a, b) = [int(o) for o in input().split()]
	s = input()
	ar = list(s)
	n = a + b
	for j in range(n):
		if ar[j] == '?':
			ar[j] = ar[n - j - 1]
	a = a - ar.count('0')
	b = b - ar.count('1')
	for j in range(n // 2 + 1):
		if j != n - j - 1 and ar[j] == '?':
			if a > 1:
				ar[j] = '0'
				ar[n - j - 1] = '0'
				a = a - 2
			elif b > 1:
				ar[j] = '1'
				ar[n - j - 1] = '1'
				b = b - 2
		elif ar[j] == '?':
			if a > 0:
				ar[j] = '0'
				a = a - 1
			elif b > 0:
				ar[j] = '1'
				b = b - 1
	if ar == ar[::-1] and a == 0 and (b == 0):
		print(''.join(ar))
	else:
		print(-1)


def f(s, a, b):
	l = list(s)
	ra = a
	rb = b
	if (a + b) % 2 == 0:
		if a % 2 == 1:
			return -1
	elif a % 2 == 1:
		if l[(a + b) // 2] == '0':
			ra = ra - 1
		elif l[(a + b) // 2] == '?':
			l[(a + b) // 2] = '0'
			ra = ra - 1
		else:
			return -1
	elif l[(a + b) // 2] == '1':
		rb = rb - 1
	elif l[(a + b) // 2] == '?':
		l[(a + b) // 2] = '1'
		rb = rb - 1
	else:
		return -1
	for i in range((a + b) // 2):
		x = l[i]
		y = l[a + b - 1 - i]
		if x == '?' and y == '0' or (x == '0' and y == '?') or (x == '0' and y == '0'):
			l[i] = '0'
			l[a + b - 1 - i] = '0'
			ra = ra - 2
		if x == '?' and y == '1' or (x == '1' and y == '?') or (x == '1' and y == '1'):
			l[i] = '1'
			l[a + b - 1 - i] = '1'
			rb = rb - 2
		if x == '1' and y == '0' or (x == '0' and y == '1'):
			return -1
	if ra < 0 or rb < 0:
		return -1
	else:
		for j in range((a + b) // 2):
			x = l[j]
			y = l[a + b - 1 - j]
			if x == '?':
				if ra != 0:
					ra = ra - 2
					l[j] = '0'
					l[a + b - 1 - j] = '0'
				else:
					rb = rb - 2
					l[j] = '1'
					l[a + b - 1 - j] = '1'
		return ''.join(l)
t = int(input())
i = 0
while i != t:
	i = i + 1
	x = input().split(' ')
	a = int(x[0])
	b = int(x[1])
	s = input()
	print(f(s, a, b))


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	(a, b) = mp()
	s = st()
	n = a + b
	for i in range((n + 1) // 2):
		if s[i] == '?' or s[n - i - 1] == '?':
			if s[i] == '?':
				s[i] = s[n - i - 1]
			else:
				s[n - i - 1] = s[i]
	p = [0, 0]
	for i in range(n):
		if s[i] != '?':
			p[int(s[i])] += 1
	for i in range((n + 1) // 2):
		if s[i] == '?' and s[n - i - 1] == '?':
			cur = 1 + (i != n - i - 1)
			if p[0] + cur <= a:
				s[i] = s[n - i - 1] = '0'
				p[0] += cur
			else:
				s[i] = s[n - i - 1] = '1'
				p[1] += cur
	if p == [a, b] and s[::-1] == s:
		print(*s, sep='')
		return
	pr(-1)
for _ in range(inp()):
	solve()


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math
from collections import defaultdict, Counter

def ceil(a, b):
	return (a + b - 1) // b
for _ in range(ri()):
	(a, b) = ria()
	l = list(rs())
	for i in range(a + b):
		if l[i] == '0':
			a -= 1
		elif l[i] == '1':
			b -= 1
	(i, j) = (0, len(l) - 1)
	while i < j:
		if l[i] == '0' and l[j] == '?' and (a > 0):
			l[j] = '0'
			a -= 1
		elif l[i] == '?' and l[j] == '0' and (a > 0):
			l[i] = '0'
			a -= 1
		elif l[i] == '1' and l[j] == '?' and (b > 0):
			l[j] = '1'
			b -= 1
		elif l[i] == '?' and l[j] == '1' and (b > 0):
			l[i] = '1'
			b -= 1
		else:
			flag = 1
		i += 1
		j -= 1
	(i, j) = (0, len(l) - 1)
	flag = 0
	while i < j:
		if l[i] == '?' and l[j] == '?':
			if a >= 2:
				l[i] = l[j] = '0'
				a -= 2
			elif b >= 2:
				l[i] = l[j] = '1'
				b -= 2
			else:
				flag = 1
		i += 1
		j -= 1
	if i == j:
		if l[i] == '?':
			if a > 0:
				l[i] = '0'
				a -= 1
			elif b > 0:
				l[i] = '1'
				b -= 1
			else:
				flag = 1
	if a != 0 or b != 0:
		flag = 1
	(i, j) = (0, len(l) - 1)
	while i < j:
		if l[i] != l[j]:
			flag = 1
			break
		i += 1
		j -= 1
	if flag:
		print(-1)
	else:
		print(''.join(l))


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]

def solve(A, B, S):
	S = list(S)
	for i in range(math.ceil(len(S) / 2)):
		j = len(S) - i - 1
		if i == j:
			if S[i] == '0':
				A -= 1
			elif S[i] == '1':
				B -= 1
		elif (S[i], S[j]) == ('0', '0'):
			A -= 2
		elif (S[i], S[j]) == ('1', '1'):
			B -= 2
		elif (S[i], S[j]) == ('0', '?'):
			A -= 2
			S[j] = '0'
		elif (S[i], S[j]) == ('?', '0'):
			A -= 2
			S[i] = '0'
		elif (S[i], S[j]) == ('1', '?'):
			B -= 2
			S[j] = '1'
		elif (S[i], S[j]) == ('?', '1'):
			B -= 2
			S[i] = '1'
		elif (S[i], S[j]) == ('0', '1') or (S[i], S[j]) == ('1', '0'):
			return '-1'
	for i in range(math.ceil(len(S) / 2)):
		j = len(S) - i - 1
		if i == j:
			if S[i] == '?':
				if A >= 1:
					S[i] = '0'
					A -= 1
				else:
					S[i] = '1'
					B -= 1
		elif S[i] == '?':
			if A >= 2:
				S[i] = '0'
				S[j] = '0'
				A -= 2
			else:
				S[i] = '1'
				S[j] = '1'
				B -= 2
	if A != 0 or B != 0:
		return '-1'
	else:
		return ''.join(S)

def main():
	T0 = int(input())
	for _ in range(T0):
		(A, B) = map(int, input().split())
		S = input()
		ans = solve(A, B, S)
		print(ans)
main()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	s = input()
	c0 = s.count('0')
	c1 = s.count('1')
	ra = a - c0
	rb = b - c1
	n = len(s)
	ans = [''] * n
	idx = []
	flag = False
	for i in range(n // 2):
		if s[i] != '?' and s[n - 1 - i] != '?' and (s[i] == s[n - 1 - i]):
			ans[i] = ans[n - 1 - i] = s[i]
		elif s[i] != '?' and s[n - 1 - i] != '?':
			print(-1)
			flag = True
			break
		elif s[i] != '?' and s[n - 1 - i] == '?':
			if s[i] == '0':
				if ra > 0:
					ra -= 1
					ans[i] = s[i]
					ans[n - 1 - i] = s[i]
				else:
					print(-1)
					flag = True
					break
			elif rb > 0:
				rb -= 1
				ans[i] = s[i]
				ans[n - 1 - i] = s[i]
			else:
				print(-1)
				flag = True
				break
		elif s[i] == '?' and s[n - 1 - i] != '?':
			if s[n - 1 - i] == '0':
				if ra > 0:
					ra -= 1
					ans[i] = s[n - i - 1]
					ans[n - 1 - i] = s[n - i - 1]
				else:
					print(-1)
					flag = True
					break
			elif rb > 0:
				rb -= 1
				ans[i] = s[n - i - 1]
				ans[n - 1 - i] = s[n - i - 1]
			else:
				print(-1)
				flag = True
				break
		else:
			idx.append(i)
	if flag:
		continue
	for ii in idx:
		if ra >= 2:
			ra -= 2
			ans[ii] = ans[n - 1 - ii] = '0'
		elif rb >= 2:
			rb -= 2
			ans[ii] = ans[n - 1 - ii] = '1'
		else:
			print(-1)
			flag = True
			break
	if n % 2 == 1:
		if s[n // 2] == '?':
			if ra > 0:
				ra -= 1
				ans[n // 2] = '0'
			elif rb > 0:
				rb -= 1
				ans[n // 2] = '1'
			else:
				print(-1)
				flag = True
				break
		else:
			ans[n // 2] = s[n // 2]
	if flag:
		continue
	if ra == 0 and rb == 0:
		print(''.join(ans))
	else:
		print(-1)


for _ in range(int(input())):
	(c_z, c_o) = map(int, input().split())
	n = c_z + c_o
	st = input()
	arr = []
	for i in st:
		arr.append(i)
	i = 0
	flag = 0
	for i in range(n):
		if arr[i] == '1':
			c_o -= 1
		elif arr[i] == '0':
			c_z -= 1
	i = 0
	while i < n - i - 1:
		if arr[i] == '?' and arr[n - i - 1] == '1':
			arr[i] = 1
			c_o -= 1
		elif arr[i] == '?' and arr[n - i - 1] == '0':
			arr[i] = 0
			c_z -= 1
		elif arr[n - i - 1] == '?' and arr[i] == '1':
			arr[n - i - 1] = 1
			c_o -= 1
		elif arr[n - i - 1] == '?' and arr[i] == '0':
			arr[n - i - 1] = 0
			c_z -= 1
		elif arr[i] == arr[n - i - 1] and (arr[i] == '?' or arr[i] == '1' or arr[i] == '0'):
			pass
		else:
			flag = 1
			break
		i += 1
	if c_o < 0 or c_z < 0 or flag == 1:
		print(-1)
		continue
	if n % 2 == 1 and c_z % 2 == 1:
		arr[n // 2] = 0
		c_z -= 1
	if n % 2 == 1 and c_o % 2 == 1:
		arr[n // 2] = 1
		c_o -= 1
	i = 0
	while i < n - i - 1:
		if arr[i] == '?' and c_z >= c_o:
			arr[i] = arr[n - i - 1] = '0'
			c_z -= 2
		elif arr[i] == '?' and c_o > c_z:
			arr[i] = arr[n - i - 1] = '1'
			c_o -= 2
		i += 1
	if c_o == c_z == 0:
		for i in range(n):
			print(arr[i], end='')
		print()
	else:
		print(-1)


T = int(input())
for _ in range(T):
	(zero, one) = map(int, input().split())
	s = [i for i in input()]
	n = zero + one
	for i in range(n):
		if s[i] == '?':
			s[i] = s[n - i - 1]
	zero -= s.count('0')
	one -= s.count('1')
	i = 0
	j = n - 1
	while i <= j:
		if i != j and s[i] == '?' and (s[j] == '?'):
			if zero > 1:
				zero -= 2
				s[j] = s[i] = '0'
			else:
				one -= 2
				s[j] = s[i] = '1'
		elif i == j and s[i] == '?':
			if one > 0:
				s[i] = '1'
				one -= 1
			elif zero > 0:
				s[i] = '0'
				zero -= 1
		i += 1
		j -= 1
	s = ''.join(s)
	if s == s[::-1] and one == zero and (one == 0):
		print(s)
	else:
		print(-1)


from math import factorial
t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	s = input()
	n = a + b
	l = [c for c in s]
	done = False
	for (i, x) in enumerate(l):
		if x != '?' and l[n - i - 1] != '?':
			if x != l[n - i - 1]:
				done = True
				break
	if done:
		print(-1)
		continue
	for (i, x) in enumerate(l):
		if x != '?':
			l[n - i - 1] = x
	a -= l.count('0')
	b -= l.count('1')
	half = n // 2
	if a % 2 and b % 2:
		print(-1)
		continue
	if a < 0 or b < 0:
		print(-1)
		continue
	if a % 2:
		l[half] = '0'
		a -= 1
	elif b % 2:
		l[half] = '1'
		b -= 1
	for (i, x) in enumerate(l):
		if x == '?':
			if a:
				l[n - i - 1] = '0'
				l[i] = '0'
				a -= 2
			else:
				l[n - i - 1] = '1'
				l[i] = '1'
				b -= 2
	print(''.join(l))


def f(zeros, ones, s):
	existing_ones = s.count('1')
	existing_zeros = s.count('0')
	needed_zeros = zeros - existing_zeros
	needed_ones = ones - existing_ones
	free_pairs = []
	needs_one = []
	needs_zero = []
	for i in range(len(s) // 2):
		(l, r) = (i, len(s) - 1 - i)
		pair = (s[l], s[r])
		if pair == ('?', '?'):
			free_pairs.append((l, r))
		elif pair == ('?', '0'):
			needs_zero.append(l)
		elif pair == ('0', '?'):
			needs_zero.append(r)
		elif pair == ('1', '?'):
			needs_one.append(r)
		elif pair == ('?', '1'):
			needs_one.append(l)
		elif pair == ('1', '0'):
			return '-1'
		elif pair == ('0', '1'):
			return '-1'
		elif pair == ('1', '1'):
			pass
		elif pair == ('0', '0'):
			pass
	arr = list(s)
	while needs_zero:
		arr[needs_zero.pop()] = '0'
		needed_zeros -= 1
	if needed_zeros < 0:
		return '-1'
	while needs_one:
		arr[needs_one.pop()] = '1'
		needed_ones -= 1
	if needed_ones < 0:
		return '-1'
	while free_pairs and needed_zeros >= 2:
		(l, r) = free_pairs.pop()
		arr[l] = arr[r] = '0'
		needed_zeros -= 2
	while free_pairs and needed_ones >= 2:
		(l, r) = free_pairs.pop()
		arr[l] = arr[r] = '1'
		needed_ones -= 2
	if free_pairs:
		return '-1'
	sum = needed_ones + needed_zeros
	if sum == 0:
		return ''.join(arr)
	elif sum == 1:
		if len(s) & 1 and s[len(s) // 2] == '?':
			arr[len(s) // 2] = '1' if needed_ones else '0'
			return ''.join(arr)
	return '-1'

def g(a, b, s):
	result = f(a, b, s)
	if result == '-1':
		return '-1'
	if result.count('0') == a and result.count('1') == b:
		return result
	else:
		return '-1'
t = int(input())
output = []
for _ in range(t):
	(a, b) = map(int, input().split())
	line = input()
	output.append(g(a, b, line))
print('\n'.join(output))


from collections import Counter
t = int(input())
for __ in range(t):
	(a, b) = map(int, input().split())
	arr = list(input())
	amap = Counter(arr)
	for j in amap.keys():
		if j == '0':
			a -= amap[j]
		elif j == '1':
			b -= amap[j]
	n = len(arr)
	ans = 0
	for j in range(len(arr) // 2):
		if arr[j] == '0' and arr[n - j - 1] == '1' or (arr[j] == '1' and arr[n - j - 1] == '0'):
			ans = 1
			break
		elif arr[j] == '0' and arr[n - j - 1] == '?':
			arr[n - j - 1] = '0'
			a -= 1
		elif arr[j] == '?' and arr[n - j - 1] == '0':
			arr[j] = '0'
			a -= 1
		elif arr[j] == '1' and arr[n - j - 1] == '?':
			arr[n - j - 1] = '1'
			b -= 1
		elif arr[j] == '?' and arr[n - j - 1] == '1':
			arr[j] = '1'
			b -= 1
	for j in range(len(arr) // 2):
		if arr[j] == '?' and arr[n - j - 1] == '?':
			if a > b:
				arr[j] = '0'
				arr[n - j - 1] = '0'
				a -= 2
			else:
				arr[j] = '1'
				arr[n - j - 1] = '1'
				b -= 2
	if n % 2 != 0 and arr[n // 2] == '?':
		if a > b:
			arr[n // 2] = '0'
			a -= 1
		else:
			arr[n // 2] = '1'
			b -= 1
	if ans == 1 or a < 0 or b < 0:
		print(-1)
	else:
		print(*arr, sep='')


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		(a, b) = mi()
		n = a + b
		s = list(si())
		i = 0
		j = n - 1
		flag = 1
		cnt = 0
		p = []
		while i <= j:
			if i == j:
				if s[i] != '?':
					if s[i] == '0':
						a -= 1
					else:
						b -= 1
					break
				else:
					if a % 2 == 1:
						a -= 1
						s[i] = '0'
					else:
						b -= 1
						s[i] = '1'
					break
			if s[i] == '0':
				a -= 1
			elif s[i] == '1':
				b -= 1
			if s[j] == '0':
				a -= 1
			elif s[j] == '1':
				b -= 1
			x = s[i]
			y = s[n - i - 1]
			if x == y and (x == '0' or x == '1'):
				i += 1
				j -= 1
				continue
			if x != '?' and y != '?':
				flag = 0
				break
			elif x != '?' or y != '?':
				if x != '?':
					s[j] = x
					if s[i] == '0':
						a -= 1
					else:
						b -= 1
				else:
					if s[j] == '0':
						a -= 1
					else:
						b -= 1
					s[i] = y
			else:
				p.append([i, j])
				cnt += 2
			i += 1
			j -= 1
		if flag == 0 or a < 0 or b < 0:
			print(-1)
			continue
		for i in range(len(p)):
			if a > 1:
				s[p[i][0]] = '0'
				s[p[i][1]] = '0'
				a -= 2
			elif b > 1:
				s[p[i][0]] = '1'
				s[p[i][1]] = '1'
				b -= 2
			else:
				flag = 0
				break
		if flag == 0:
			print(-1)
			continue
		for i in s:
			print(i, end='')
		print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import Counter
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(str(input()))
	n = len(s)
	x = s.count('0')
	y = s.count('1')
	a -= x
	b -= y
	t = 1
	if a < 0 or b < 0:
		print(-1)
		continue
	for i in range(n // 2):
		if s[i] != '?' or s[n - i - 1] != '?':
			if s[i] != '?' and s[n - i - 1] != '?':
				if s[i] != s[n - i - 1]:
					t = 0
					break
			if s[i] == '0' or s[n - i - 1] == '0':
				if s[i] != s[n - i - 1]:
					a -= 1
				s[n - i - 1] = '0'
				s[i] = '0'
			else:
				if s[i] != s[n - i - 1]:
					b -= 1
				s[n - i - 1] = '1'
				s[i] = '1'
		if a < 0 or b < 0:
			t = 0
			break
	for i in range(n // 2):
		if s[i] == '?' and s[n - i - 1] == '?':
			if a >= b:
				a -= 2
				s[i] = '0'
				s[n - i - 1] = '0'
			else:
				b -= 2
				s[i] = '1'
				s[n - i - 1] = '1'
		if a < 0 or b < 0:
			t = 0
			break
	if n % 2:
		if s[n // 2] == '?':
			if a == 1:
				s[n // 2] = '0'
			elif b == 1:
				s[n // 2] = '1'
			else:
				t = 0
	if a != 0 and b != 0:
		t = 0
	if t:
		print(''.join(s))
	else:
		print(-1)


def abpal():
	(a, b) = map(int, input().split())
	s = input()
	n = len(s)
	if a + b != n:
		return -1
	if a % 2 != 0 and b % 2 != 0:
		return -1
	if n == 1:
		if a == 1 and s == '0':
			return s
		if b == 1 and s == '1':
			return s
		if s == '?':
			if a == 1:
				return '0'
			if b == 1:
				return '1'
		return -1
	ac = s.count('0')
	bc = s.count('1')
	if s.count('?') == 0:
		if ac != a or bc != b:
			return -1
		if s == s[::-1]:
			return s
		else:
			return -1
	st = ''
	for i in range(n // 2):
		if s[i] == '?':
			if s[n - i - 1] == '?':
				st = st + '?'
			else:
				st = st + s[n - i - 1]
		else:
			st = st + s[i]
	rev = st[::-1]
	if n % 2 != 0:
		if a % 2 != 0:
			st = st + '0'
		else:
			st = st + '1'
	st = st + rev
	if st != st[::-1]:
		return -1
	ac = st.count('0')
	bc = st.count('1')
	stg = ''
	for i in range(n // 2):
		if st[i] == '?':
			if ac < a:
				ac += 2
				stg = stg + '0'
			else:
				bc += 2
				stg = stg + '1'
		else:
			stg = stg + st[i]
	rev = stg[::-1]
	if n % 2 != 0:
		if a % 2 != 0:
			stg = stg + '0'
		else:
			stg = stg + '1'
	stg = stg + rev
	ac = stg.count('0')
	bc = stg.count('1')
	if a != ac or b != bc:
		return -1
	if stg != stg[::-1]:
		return -1
	for i in range(n):
		if s[i] != '?':
			if s[i] != stg[i]:
				return -1
	return stg
n = int(input())
for i in range(n):
	print(abpal())


from collections import Counter

def solve(st, a, b):
	li = list(st)
	n = a + b
	for i in range(len(li) // 2):
		if li[i] != li[n - i - 1]:
			if li[i] == '0' and li[n - i - 1] == '1':
				return -1
			if li[i] == '1' and li[n - i - 1] == '0':
				return -1
			if li[i] == '?':
				li[i] = li[n - i - 1]
			else:
				li[n - i - 1] = li[i]
	C = Counter(li)
	(c0, c1) = (C['0'], C['1'])
	if c0 > a or c1 > b:
		return -1
	for i in range(len(li) // 2):
		if li[i] == '?':
			if c0 + 2 <= a:
				li[i] = li[n - i - 1] = '0'
				c0 += 2
			elif c1 + 2 <= b:
				li[i] = li[n - i - 1] = '1'
				c1 += 2
			else:
				return -1
	if n % 2:
		if li[n // 2] == '?':
			if c0 + 1 <= a:
				c0 += 1
				li[n // 2] = '0'
			elif c1 + 1 <= b:
				c1 += 1
				li[n // 2] = '1'
			else:
				return -1
	return ''.join(li)
for case in range(int(input())):
	(a, b) = map(int, input().split())
	st = input()
	ans = solve(st, a, b)
	print(ans)


def getPalindrome(s, countMap):
	(l, r) = (0, len(s) - 1)
	isPossible = True
	while l <= r:
		if s[l] != s[r]:
			if s[l] == '?':
				s[l] = s[r]
				countMap[s[r]] -= 1
			elif s[r] == '?':
				s[r] = s[l]
				countMap[s[l]] -= 1
			else:
				isPossible = False
				break
		l += 1
		r -= 1
	(l, r) = (0, len(s) - 1)
	while l <= r:
		c = 1 if l == r else 2
		if s[l] == '?' and s[r] == '?':
			if countMap['0'] >= c:
				s[l] = s[r] = '0'
				countMap['0'] -= c
			elif countMap['1'] >= c:
				s[l] = s[r] = '1'
				countMap['1'] -= c
			else:
				isPossible = False
				break
		l += 1
		r -= 1
	if not isPossible or countMap['0'] != 0 or countMap['1'] != 0:
		return -1
	return ''.join(s)
t = int(input())
while t:
	(a, b) = map(int, input().split())
	s = input()
	countMap = {}
	for val in s:
		countMap[val] = countMap.get(val, 0) + 1
	countMap['0'] = a - countMap.get('0', 0)
	countMap['1'] = b - countMap.get('1', 0)
	print(getPalindrome(list(s), countMap))
	t -= 1


for pratyush in range(int(input())):
	(a, b) = list(map(int, input().split()))
	s = list(input())
	(f, n) = (1, len(s))
	for i in range(n // 2):
		j = n - 1 - i
		if s[i] == '0' and s[j] == '0':
			a -= 2
		elif s[i] == '1' and s[j] == '1':
			b -= 2
		elif s[i] == '?' and s[j] == '0':
			s[i] = '0'
			a -= 2
		elif s[i] == '0' and s[j] == '?':
			s[j] = '0'
			a -= 2
		elif s[i] == '?' and s[j] == '1':
			b -= 2
			s[i] = '1'
		elif s[i] == '1' and s[j] == '?':
			b -= 2
			s[j] = '1'
	for i in range(n // 2):
		j = n - 1 - i
		if s[i] == '?' and s[j] == '?':
			if a >= 2:
				a -= 2
				s[i] = s[j] = '0'
			elif b >= 2:
				b -= 2
				s[i] = s[j] = '1'
	if n % 2 == 0:
		if a != 0 or b != 0:
			f = 0
	elif s[n // 2] == '?':
		if a == 1 and b == 0:
			s[n // 2] = '0'
			a -= 1
		elif a == 0 and b == 1:
			b -= 1
			s[n // 2] = '1'
		else:
			f = 0
	elif s[n // 2] == '0':
		a -= 1
	elif s[n // 2] == '1':
		b -= 1
	if f and a == 0 and (b == 0):
		print(''.join(s))
	else:
		print(-1)


for ttt in range(int(input())):
	(zero, one) = map(int, input().split())
	s = list(input())
	n = len(s)
	for i in range(n // 2):
		if s[i] != '?' and s[n - i - 1] == '?':
			s[n - i - 1] = s[i]
		elif s[i] == '?' and s[n - i - 1] != '?':
			s[i] = s[n - i - 1]
	zero -= s.count('0')
	one -= s.count('1')
	for i in range(len(s) // 2):
		if s[i] == '?' and s[n - i - 1] == '?':
			if one >= 2:
				s[i] = '1'
				s[n - i - 1] = '1'
				one -= 2
			elif zero >= 2:
				s[i] = '0'
				s[n - i - 1] = '0'
				zero -= 2
	if n % 2:
		if s[n // 2] == '?':
			if one:
				s[n // 2] = '1'
				one -= 1
			elif zero:
				s[n // 2] = '0'
				zero -= 1
	s = ''.join(s)
	if s == s[::-1] and (not one) and (not zero) and (s.count('?') <= 0):
		print(s)
	else:
		print(-1)


import sys
input = sys.stdin.readline

def main():
	tc = int(input())
	for _ in range(tc):
		(a, b) = [int(_) for _ in input().split()]
		s = [ch for ch in input().rstrip()]
		flag = False
		for (i, ch) in enumerate(s):
			if ch != '?':
				if s[~i] == '?':
					s[~i] = ch
				elif ch != s[~i]:
					print('-1')
					flag = True
					break
		if flag:
			continue
		a -= s.count('0')
		b -= s.count('1')
		ab = s.count('?')
		if a + b != ab or a < 0 or b < 0 or (a % 2 == 1 and b % 2 == 1):
			print('-1')
			continue
		if a % 2 == 1 or b % 2 == 1:
			mid = len(s) // 2
			if s[mid] != '?':
				print('-1')
				continue
			if a % 2 == 1:
				s[mid] = '0'
				a -= 1
			else:
				s[mid] = '1'
				b -= 1
		for i in range(len(s)):
			if s[i] == '?':
				if a > 0:
					s[i] = '0'
					s[~i] = '0'
					a -= 2
				elif b > 0:
					s[i] = '1'
					s[~i] = '1'
					b -= 2
		print(''.join(s))
main()


for nt in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input())
	n = a + b
	if a % 2 and b % 2:
		print(-1)
		continue
	flag = False
	for i in range(n // 2):
		if s[i] == '?' and s[n - i - 1] == '?':
			continue
		if s[i] == '?':
			s[i] = s[n - i - 1]
		elif s[n - i - 1] == '?':
			s[n - i - 1] = s[i]
		elif s[i] != s[n - i - 1]:
			flag = True
			break
	if flag:
		print(-1)
		continue
	a -= s.count('0')
	b -= s.count('1')
	for i in range(n // 2):
		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:
		if s[n // 2] == '?':
			if a:
				s[n // 2] = '0'
				a -= 1
			else:
				s[n // 2] = '1'
				b -= 1
	if a == 0 and b == 0 and (s.count('?') == 0):
		print(''.join(s))
	else:
		print(-1)


from itertools import count
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	n = x + y
	a = list(input())
	for i in range(n):
		if a[i] == '?':
			a[i] = a[n - i - 1]
	x -= a.count('0')
	y -= a.count('1')
	i = 0
	j = n - 1
	z = True
	while j >= i:
		if i != j and a[i] == '?':
			if x > 1:
				a[i] = a[n - i - 1] = '0'
				x -= 2
			elif y > 1:
				a[i] = a[n - i - 1] = '1'
				y -= 2
		elif a[i] == '?':
			if x > 0:
				a[i] = '0'
				x -= 1
			elif y > 0:
				a[i] = '1'
				y -= 1
		i += 1
		j -= 1
	if a == a[::-1] and x == y and (x == 0):
		print(''.join(a))
	else:
		print(-1)


for t in range(int(input())):
	(a, b) = map(int, input().split())
	s = input()
	pos = []
	t = True
	s = list(s)
	for i in range(len(s) // 2):
		if s[i] == '0':
			a -= 1
			if s[len(s) - i - 1] == '?':
				s[len(s) - i - 1] = '0'
				a -= 1
			elif s[len(s) - i - 1] == '0':
				a -= 1
			else:
				t = False
				break
		elif s[i] == '1':
			b -= 1
			if s[len(s) - i - 1] == '?':
				s[len(s) - i - 1] = '1'
				b -= 1
			elif s[len(s) - i - 1] == '1':
				b -= 1
			else:
				t = False
				break
		elif s[i] == '?':
			if s[len(s) - i - 1] == '0':
				a -= 2
				s[i] = '0'
			elif s[len(s) - 1 - i] == '1':
				b -= 2
				s[i] = '1'
	is_ = False
	if len(s) % 2 == 1:
		if s[len(s) // 2] == '0':
			a -= 1
		elif s[len(s) // 2] == '1':
			b -= 1
	for i in range(len(s) // 2):
		if s[i] == '?':
			if a > 1:
				a -= 2
				s[i] = '0'
				s[len(s) - i - 1] = '0'
			else:
				b -= 2
				s[i] = '1'
				s[len(s) - i - 1] = '1'
	if len(s) % 2 == 1:
		if s[len(s) // 2] == '0':
			pass
		elif s[len(s) // 2] == '1':
			pass
		elif a > 0:
			a -= 1
			s[len(s) // 2] = '0'
		else:
			b -= 1
			s[len(s) // 2] = '1'
	if a == 0 and b == 0:
		print(''.join(s))
	else:
		print(-1)


for i in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	s = [x for x in input()]
	if a == s.count('0') and b == s.count('1'):
		if s == s[::-1]:
			print(''.join(s))
		else:
			print(-1)
	elif a % 2 == 1 and b % 2 == 1 and (len(s) % 2 == 0):
		print(-1)
	elif s.count('0') > a or s.count('1') > b:
		print(-1)
	else:
		a -= s.count('0')
		b -= s.count('1')
		for j in range(len(s)):
			if s[j] == '0':
				if s[-j - 1] == '?':
					s[-j - 1] = '0'
					a -= 1
			elif s[j] == '1':
				if s[-j - 1] == '?':
					s[-j - 1] = '1'
					b -= 1
		for k in range(len(s)):
			if s[k] == '?':
				if a > 1:
					s[k] = '0'
					s[-k - 1] = '0'
					a -= 2
				elif b > 1:
					s[k] = '1'
					s[-k - 1] = '1'
					b -= 2
				elif a == 1:
					s[k] = '0'
					a -= 1
				elif b == 1:
					s[k] = '1'
					b -= 1
		s = ''.join(s)
		if a == b == 0 and s == s[::-1]:
			print(s)
		else:
			print(-1)


def solve_tc():
	(a, b) = map(int, input().split())
	s = list(input())
	if len(s) % 2 == 1 and len(s) > 2:
		if s[len(s) // 2] == '1':
			b -= 1
		elif s[len(s) // 2] == '0':
			a -= 1
	for i in range(len(s) // 2):
		rev = -i - 1
		if s[i] == '1':
			b -= 1
			if s[rev] == '?':
				s[rev] = '1'
				b -= 1
			elif s[rev] == '1':
				b -= 1
			else:
				return '-1'
		if s[i] == '0':
			a -= 1
			if s[rev] == '?':
				s[rev] = '0'
				a -= 1
			elif s[rev] == '0':
				a -= 1
			else:
				return '-1'
		if s[i] == '?':
			if s[rev] == '0':
				s[i] = '0'
				a -= 2
			elif s[rev] == '1':
				s[i] = '1'
				b -= 2
	if a < 0 or b < 0:
		return '-1'
	for i in range(len(s) // 2):
		if s[i] == '?':
			if a >= b:
				s[i] = s[-i - 1] = '0'
				a -= 2
			else:
				s[i] = s[-i - 1] = '1'
				b -= 2
	if a < 0 or b < 0:
		return '-1'
	if len(s) % 2 == 1:
		if len(s) > 2:
			if s[len(s) // 2] == '?':
				if a == 1:
					s[len(s) // 2] = '0'
				else:
					s[len(s) // 2] = '1'
		elif s[0] == '?':
			if a == 1:
				s = ['0']
			else:
				s = ['1']
		elif s[0] == '0':
			if a == 1:
				return '0'
			else:
				return '-1'
		elif s[0] == '1':
			if b == 1:
				return '1'
			else:
				return '-1'
	return s
t = int(input())
while t > 0:
	t -= 1
	print(''.join(solve_tc()))


t = int(input())
while t:
	t -= 1
	m = list(map(int, input().split(' ')))
	(a, b) = (m[0], m[1])
	string = list(input())
	flag = False
	if (a + b) % 2 != 0:
		if string[len(string) // 2] == '?':
			string[len(string) // 2] = '0' if a % 2 != 0 else '1'
	for i in range(len(string)):
		if string[i] == '?':
			string[i] = string[-(i + 1)]
	a -= string.count('0')
	b -= string.count('1')
	for i in range(len(string)):
		if string[i] == '?':
			if a > 1:
				string[i] = string[-(i + 1)] = '0'
				a -= 2
			elif b > 1:
				string[i] = string[-(i + 1)] = '1'
				b -= 2
	if string == string[::-1] and a == 0 and (b == 0):
		print(''.join(string))
	else:
		print(-1)


def solve(a, b, s):
	n = len(s)
	for i in range(n // 2):
		j = n - i - 1
		if s[i] == s[j] != '?':
			if s[i] == '0':
				a -= 2
			else:
				b -= 2
		elif s[i] != '?' and s[j] == '?':
			s[j] = s[i]
			if s[j] == '0':
				a -= 2
			else:
				b -= 2
		elif s[i] == '?' and s[j] != '?':
			s[i] = s[j]
			if s[j] == '0':
				a -= 2
			else:
				b -= 2
	if n & 1:
		if s[n // 2] == '?':
			if a & 1:
				s[n // 2] = '0'
				a -= 1
			else:
				s[n // 2] = '1'
				b -= 1
		elif s[n // 2] == '0':
			a -= 1
		else:
			b -= 1
	for i in range(n // 2):
		j = n - i - 1
		if s[i] != '?':
			continue
		if a >= 2:
			s[i] = s[j] = '0'
			a -= 2
		elif b >= 2:
			s[i] = s[j] = '1'
			b -= 2
		else:
			break
	if a > 0 or b > 0:
		return -1
	return ''.join(s)
for _ in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	s = list(input().strip())
	print(solve(a, b, s))


import math
import sys
from collections import *
import itertools

def cint():
	return list(map(int, sys.stdin.readline().strip().split()))

def cstr():
	return list(map(str, input().split(' ')))

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def solve(t):
	(a, b) = cint()
	lst = [i for i in input()]
	n = len(lst)
	for i in range(n // 2):
		if lst[i] != '?' and lst[n - i - 1] == '?':
			lst[n - i - 1] = lst[i]
		elif lst[i] == '?' and lst[n - i - 1] != '?':
			lst[i] = lst[n - i - 1]
	c1 = 0
	c0 = 0
	for i in range(n):
		if lst[i] == '0':
			c0 += 1
		elif lst[i] == '1':
			c1 += 1
	if c0 > a or c1 > b:
		print(-1)
		return
	for i in range(n):
		if lst[i] == '?':
			if i != n - i - 1:
				if c0 + 2 <= a:
					c0 += 2
					lst[i] = lst[n - i - 1] = '0'
				elif c1 + 2 <= b:
					c1 += 2
					lst[i] = lst[n - i - 1] = '1'
			elif c0 + 1 <= a:
				c0 += 1
				lst[i] = lst[n - i - 1] = '0'
			elif c1 + 1 <= b:
				c1 += 1
				lst[i] = lst[n - i - 1] = '1'

	def palindrome(lst):
		if len(lst) == 1:
			return True
		for i in range(n // 2):
			if lst[i] != lst[n - i - 1]:
				return False
		return True
	if c0 == a and c1 == b:
		if palindrome(lst):
			print(''.join(lst))
		else:
			print(-1)
	else:
		print(-1)
t = int(input())
for i in range(1, t + 1):
	solve(i)


def solve():
	(z, b) = map(int, input().split(' '))
	z1 = z
	b1 = b
	a = input()
	a = list(a)
	n = z + b
	for i in range((n + 1) // 2):
		if a[i] != '?' and a[n - i - 1] == '?':
			a[n - i - 1] = a[i]
		elif a[i] == '?' and a[n - i - 1] != '?':
			a[i] = a[n - i - 1]
		if a[i] != '?' and a[n - i - 1] != '?' and (a[n - i - 1] != a[i]):
			return -1
	z -= a.count('0')
	b -= a.count('1')
	for i in range((n + 1) // 2):
		if z > b and z > 1 and (a[i] == '?'):
			a[i] = a[n - i - 1] = '0'
			z -= 2
		elif b > 1 and a[i] == '?':
			a[i] = a[n - i - 1] = '1'
			b -= 2
	if n % 2 == 1:
		i = n // 2
		if z == 1 and a[i] == '?':
			a[i] = '0'
			z -= 1
		elif b == 1 and a[i] == '?':
			a[i] = '1'
			b -= 1
	a = ''.join(a)
	if a.count('0') != z1 or a.count('1') != b1 or a != a[::-1]:
		return -1
	else:
		return a
t = int(input())
for i in range(t):
	print(solve())


def do():
	(a, b) = list(map(int, input().split()))
	n = a + b
	s = list(input())
	for i in range(n // 2):
		if s[i] != '?' and s[n - i - 1] == '?':
			s[n - i - 1] = s[i]
		elif s[i] == '?' and s[n - i - 1] != '?':
			s[i] = s[n - i - 1]
		elif s[i] != s[n - i - 1]:
			return '-1'
	acount = s.count('0')
	bcount = s.count('1')
	for i in range(n // 2):
		if s[i] == '?' and s[n - i - 1] == '?':
			if acount + 2 <= a:
				acount += 2
				s[i] = '0'
				s[n - i - 1] = '0'
			elif bcount + 2 <= b:
				bcount += 2
				s[i] = '1'
				s[n - i - 1] = '1'
			else:
				return '-1'
				break
	if n % 2 == 1 and s[n // 2] == '?':
		if acount <= a and acount + 1 >= a and (bcount <= b) and (bcount + 1 >= b):
			if acount == a:
				s[n // 2] = '1'
				bcount += 1
			elif bcount == b:
				s[n // 2] = '0'
				acount += 1
	if acount == a and bcount == b:
		res = ''.join(s)
		return res
	else:
		return '-1'
T = int(input())
for testcase in range(1, T + 1):
	print(do())


t = int(input())
for _ in range(t):
	(a, b) = [int(s) for s in input().split(' ')]
	s = input()
	l = a + b
	a -= s.count('0')
	b -= s.count('1')
	s = list(s)
	ans = None
	for i in range(l // 2):
		if s[i] == s[l - i - 1]:
			if s[i] == '?':
				s[i] = '*'
		elif s[i] == '1':
			if s[l - i - 1] == '0':
				ans = -1
				break
			else:
				s[l - i - 1] = '1'
				b -= 1
		elif s[i] == '0':
			if s[l - i - 1] == '1':
				ans = -1
				break
			else:
				s[l - i - 1] = '0'
				a -= 1
		else:
			s[i] = s[l - i - 1]
			if s[i] == '1':
				b -= 1
			else:
				a -= 1
	for i in range(l // 2):
		if s[i] == '*':
			if a >= 2:
				s[i] = '0'
				s[l - i - 1] = '0'
				a -= 2
			else:
				s[i] = '1'
				s[l - i - 1] = '1'
				b -= 2
	if s[l // 2] == '?':
		if a:
			s[l // 2] = '0'
			a -= 1
		else:
			s[l // 2] = '1'
			b -= 1
	if a == 0 and b == 0 and (ans != -1):
		print(''.join(s))
	else:
		print(-1)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	s = str(input())
	s1 = list(s)
	s2 = s1[::-1]
	y = s1.count('1')
	z = s2.count('0')
	a = a - z
	b = b - y
	m = len(s)
	k = len(s) // 2
	for i in range(0, m):
		if s1[i] == '?' and s2[i] != '?':
			o = s2[i]
			s1[i] = o
			if o == '1':
				b = b - 1
			else:
				a = a - 1
	for i in range(0, k):
		if s1[i] == '?':
			if a >= b:
				s1[i] = '0'
				s1[m - 1 - i] = '0'
				a = a - 2
			else:
				s1[i] = '1'
				s1[m - 1 - i] = '1'
				b = b - 2
	if m % 2 != 0:
		if a > b:
			s1[k] = '0'
			a = a - 1
		elif b > a:
			s1[k] = '1'
			b = b - 1
	if a != 0 or b != 0:
		print('-1')
	else:
		u = ''
		for i in s1:
			u = u + i
		if s1 == s1[::-1]:
			print(u)
		else:
			print(-1)


from collections import Counter
from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(a, b) = map(int, stdin.readline().split())
	l = list(input())
	ll = l.copy()
	a = a - l.count('0')
	b = b - l.count('1')
	n = len(l)
	c = False
	x = []
	for i in range(n // 2):
		if l[i] == l[n - i - 1]:
			if l[i] == '?':
				x.append(i)
		elif l[i] == '?':
			if l[n - i - 1] == '0' and a > 0:
				l[i] = '0'
				a = a - 1
			elif l[n - i - 1] == '1' and b > 0:
				l[i] = '1'
				b = b - 1
			else:
				c = True
				break
		elif l[n - i - 1] == '?':
			if l[i] == '0' and a > 0:
				l[n - i - 1] = '0'
				a = a - 1
			elif l[i] == '1' and b > 0:
				l[n - i - 1] = '1'
				b = b - 1
			else:
				c = True
				break
	for i in x:
		if a >= 2:
			l[i] = '0'
			l[n - i - 1] = '0'
			a = a - 2
		elif b >= 2:
			l[i] = '1'
			l[n - i - 1] = '1'
			b = b - 2
		else:
			c = True
			break
	if c == True:
		print(-1)
	else:
		if n == 1:
			if l[0] == '0':
				if a == 0 and b == 0:
					print(0)
				else:
					print(-1)
			elif l[0] == '1':
				if a == 0 and b == 0:
					print(1)
				else:
					print(-1)
			elif l[0] == '?':
				if a == 0 and b == 1:
					print(1)
				elif a == 1 and b == 0:
					print(0)
				else:
					print(-1)
		elif n % 2 != 0:
			ind = n // 2
			if l[ind] == '?':
				if a != 0:
					l[ind] = '0'
					a = a - 1
				elif b != 0:
					l[ind] = '1'
					b = b - 1
		if n != 1:
			count = 0
			for i in range(n):
				if l[i] == '?':
					count += 1
			if count > 0 or a != 0 or b != 0:
				print(-1)
			elif l != list(reversed(l)):
				print(-1)
			else:
				print(''.join(l))


for i in range(int(input())):
	(k, m) = map(int, input().split())
	s = list(input())
	l = len(s)
	for i in range(l):
		if s[i] == '?':
			s[i] = s[-i - 1]
	k = k - s.count('0')
	m = m - s.count('1')
	i = 0
	j = l - 1
	while i <= j:
		if s[i] == '?':
			if i != j:
				if k > 1:
					s[i] = s[j] = '0'
					k -= 2
				elif m > 1:
					s[i] = s[j] = '1'
					m -= 2
			elif i == j:
				if k % 2 == 0:
					s[i] = '1'
					m -= 1
				else:
					s[i] = '0'
					k -= 1
		i += 1
		j -= 1
	s = ''.join(s)
	stt = s[::-1]
	if s == stt and k == m == 0:
		print(s)
	else:
		print(-1)


from collections import defaultdict
for z in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input())
	d = defaultdict(int)
	for i in s:
		d[i] += 1
	if a % 2 == 1 and b % 2 == 1:
		print(-1)
		continue
	if d['?'] == 0:
		if s != s[::-1] or d['0'] != a or d['1'] != b:
			print(-1)
			continue
	req_0 = a - d['0']
	req_1 = b - d['1']
	if req_0 < 0 or req_1 < 0:
		print(-1)
		continue
	n = len(s)
	r = True
	for i in range(n):
		if s[i] == '0':
			if s[n - i - 1] == '?':
				if not req_0:
					r = False
					break
				s[n - i - 1] = '0'
				req_0 -= 1
		elif s[i] == '1':
			if s[n - i - 1] == '?':
				if not req_1:
					r = False
					break
				s[n - i - 1] = '1'
				req_1 -= 1
	for i in range(n):
		middle = False
		if s[i] == '?':
			if n % 2 == 1:
				if i == n // 2:
					middle = True
					if req_0:
						s[i] = '0'
						req_0 -= 1
					elif req_1:
						s[i] = '1'
						req_1 -= 1
			if not middle:
				if req_0 >= 2:
					s[i] = '0'
					s[n - i - 1] = '0'
					req_0 -= 2
				elif req_1 >= 2:
					s[i] = '1'
					s[n - i - 1] = '1'
					req_1 -= 2
				else:
					r = False
					break
	if s != s[::-1]:
		r = False
	if r:
		ans = ''
		for i in s:
			ans += i
		print(ans)
	else:
		print(-1)


for _ in range(int(input())):
	(a, b) = [int(t) for t in input().split()]
	s = list(input())
	n = a + b
	rem = {'0': a - s.count('0'), '1': b - s.count('1')}
	verdict = min(rem.values()) >= 0
	for i in range(n):
		j = n - i - 1
		if s[i] != '?' and s[j] != '?':
			if s[i] != s[j]:
				verdict = False
		elif s[i] != '?':
			if rem[s[i]] < 1:
				verdict = False
			s[j] = s[i]
			rem[s[i]] -= 1
	for i in range(n):
		j = n - i - 1
		if s[i] == '?':
			c = max(rem, key=lambda k: rem[k])
			uses = 2 if i != j else 1
			if rem[c] < uses:
				verdict = False
			s[i] = s[j] = c
			rem[c] -= uses
	if verdict:
		print(''.join(s))
	else:
		print(-1)


t = int(input())
for x in range(t):
	(a, b) = map(int, input().split())
	y = a
	z = b
	s = list(map(str, input()))
	e = len(s) - 1
	n = e + 1
	for i in range(len(s) // 2):
		if s[i] == '?' and s[n - i - 1] != '?':
			s[i] = s[n - i - 1]
		elif s[i] != '?' and s[n - i - 1] == '?':
			s[n - i - 1] = s[i]
	a = a - s.count('0')
	b = b - s.count('1')
	i = 0
	while i <= e:
		if s[i] == '?':
			if a >= b and a > 0:
				if a > 1:
					s[i] = '0'
					s[e] = '0'
					a = a - 2
				elif e - i <= 1:
					s[i] = '0'
					a = a - 1
			elif b > a and b > 0:
				if b > 1:
					s[i] = '1'
					s[n - i - 1] = '1'
					b = b - 2
				elif e - i <= 1:
					s[i] = '1'
					b = b - 1
		i = i + 1
		e = e - 1
	i = 0
	while i < n:
		if s[i] == '?':
			s.pop(i)
			n = n - 1
		else:
			i = i + 1
	i = 0
	e = n - 1
	a = y - s.count('0')
	b = z - s.count('1')
	while a < 0 and i < e:
		if s[i] == '0':
			s.pop(i)
			e = e - 1
			s.pop(e)
			n = n - 2
			a = a + 2
		i = i + 1
		e = e - 1
	i = 0
	e = n - 1
	while b < 0 and i < e:
		if s[i] == '1':
			s.pop(i)
			e = e - 1
			s.pop(e)
			n = n - 2
			b = b + 2
		i = i + 1
		e = e - 1
	if '?' in s or a != 0 or b != 0:
		print(-1)
	elif s == s[::-1]:
		print(*s, sep='')
	else:
		print(-1)


import math
rr = input
rri = lambda : int(rr())
rrm = lambda : list(map(int, rr().split()))
T = rri()

def split(word):
	return [char for char in word]

def solve():
	(a, b) = rrm()
	s = split(input())
	if a % 2 == 1 and b % 2 == 1:
		return -1
	n = a + b
	if n % 2 == 1:
		if a % 2:
			if s[n // 2] == '1':
				return -1
			s[n // 2] = '0'
		elif b % 2:
			if s[n // 2] == '0':
				return -1
			s[n // 2] = '1'
	ac = s.count('0')
	bc = s.count('1')
	if ac > a or bc > b:
		return -1
	aleft = a - ac
	bleft = b - bc
	for i in range(n // 2):
		temp1 = s[i]
		temp2 = s[-i - 1]
		if temp2 != temp1:
			if temp2 == '?':
				s[-i - 1] = temp1
			elif temp1 == '?':
				s[i] = temp2
			else:
				return -1
			if s[i] == '0':
				aleft -= 1
			else:
				bleft -= 1
	if bleft < 0 or aleft < 0:
		return -1
	for i in range(n // 2):
		temp1 = s[i]
		temp2 = s[-i - 1]
		if temp2 == temp1 == '?':
			if aleft > 1:
				s[-i - 1] = '0'
				s[i] = '0'
				aleft -= 2
			elif bleft > 1:
				s[-i - 1] = '1'
				s[i] = '1'
				bleft -= 2
			else:
				return -1
	if aleft or bleft:
		return -1
	if '?' in s:
		return -1
	return ''.join(s)
for t in range(T):
	print(solve())


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	s = list(input())
	for i in range(a + b):
		if s[i] == '?':
			s[i] = s[~i]
	ones = s.count('1')
	zeroes = s.count('0')
	if zeroes <= a and ones <= b:
		for i in range(a + b):
			if (a + b) % 2 and i == (a + b) // 2:
				continue
			if s[i] == '?':
				if ones + 2 <= b:
					s[i] = '1'
					s[~i] = '1'
					ones += 2
				elif zeroes + 2 <= a:
					s[i] = '0'
					s[~i] = '0'
					zeroes += 2
		s = ''.join(s)
		if a != zeroes:
			zeroes += s.count('?')
			s = s.replace('?', '0')
		if b != ones:
			ones += s.count('?')
			s = s.replace('?', '1')
	if s.count('0') == a and s.count('1') == b and (s[::-1] == s):
		print(s)
	else:
		print(-1)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(sa, sb) = (a, b)
	arr = list(input().strip())
	n = len(arr)
	flag = 1
	for i in range(n // 2):
		if arr[i] == '?' and arr[n - 1 - i] != '?':
			arr[i] = arr[n - i - 1]
		elif arr[n - i - 1] == '?' and arr[i] != '?':
			arr[n - i - 1] = arr[i]
	if n % 2 and arr[n // 2] == '?':
		arr[n // 2] = '0' if a % 2 else '1'
	a = a - arr.count('0')
	b = b - arr.count('1')
	for i in range(n // 2):
		if arr[i] == '?' and arr[n - i - 1] == '?':
			if a >= b:
				(arr[i], arr[n - i - 1]) = ('0', '0')
				a -= 2
			else:
				b -= 2
				(arr[i], arr[n - i - 1]) = ('1', '1')
	if arr.count('?') == 0 and arr.count('0') == sa and (sb == arr.count('1')) and (arr == arr[::-1]):
		print(''.join(arr))
	else:
		print(-1)


def solution():
	(a, b) = [int(i) for i in input().split()]
	s = list(input())
	n = len(s)
	empty_pairs_count = 0
	empty_pairs = []
	for i in range(0, n // 2):
		j = n - i - 1
		if s[i] != '?' and s[j] == '?':
			s[j] = s[i]
		elif s[i] == '?' and s[j] != '?':
			s[i] = s[j]
		elif s[i] == '?' and s[j] == '?':
			empty_pairs_count += 1
			empty_pairs.append((i, j))
		elif s[i] != s[j] and s[i] != '?' and (s[j] != '?'):
			print(-1)
			return
		if s[i] == '0':
			a -= 2
		elif s[j] == '1':
			b -= 2
	if a < 0 or b < 0:
		print(-1)
		return
	mid_empty = False
	if n % 2 == 1:
		if s[n // 2] != '?':
			if s[n // 2] == '0':
				a -= 1
			else:
				b -= 1
		else:
			mid_empty = True
	if a % 2 == 1:
		if mid_empty:
			s[n // 2] = '0'
			mid_empty = False
			a -= 1
		else:
			print(-1)
			return
	if b % 2 == 1:
		if mid_empty:
			s[n // 2] = '1'
			mid_empty = False
			b -= 1
		else:
			print(-1)
			return
	if (a + b) // 2 != empty_pairs_count:
		print(-1)
		return
	a_c = a / 2
	b_c = b / 2
	while empty_pairs:
		pair = empty_pairs.pop()
		if a_c > 0:
			s[pair[0]] = '0'
			s[pair[1]] = '0'
			a_c -= 1
		else:
			s[pair[0]] = '1'
			s[pair[1]] = '1'
			b_c -= 1
	print(''.join(s))
t = int(input())
for i in range(t):
	solution()


def solve(s, a, b):
	n = len(s)
	li = list(s)
	for i in range(n):
		j = n - i - 1
		if li[i] != '?':
			if li[j] == '?':
				li[j] = li[i]
			elif li[i] != li[j]:
				return -1
	if n % 2 == 1:
		if li[n // 2] == '?':
			if a % 2 == 1:
				li[n // 2] = '0'
			elif b % 2 == 1:
				li[n // 2] = '1'
			else:
				return -1
	a -= li.count('0')
	b -= li.count('1')
	for i in range(n // 2):
		j = n - i - 1
		if li[i] == '?':
			if a > 1:
				li[i] = li[j] = '0'
				a -= 2
			elif b > 1:
				li[i] = li[j] = '1'
				b -= 2
			else:
				return -1
	if a != 0 or b != 0:
		return -1
	res = ''
	for x in li:
		res += x
	return res
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = input().strip()
	print(solve(s, a, b))


def solve():
	(a, b) = map(int, input().split(' '))
	s = [c for c in input()]
	l = len(s)
	s_ = s[::-1]
	if l % 2 != 0:
		if a % 2 != 0:
			s[l // 2] = '0'
		elif b % 2 != 0:
			s[l // 2] = '1'
	for i in range(l):
		if s_[i] != '?':
			s[i] = s_[i]
	(a, b) = (a - s.count('0'), b - s.count('1'))
	for i in range(l // 2):
		if s[i] == '?':
			if a > 0:
				if s[l - i - 1] == '?':
					a -= 1
				a -= 1
				(s[i], s[l - i - 1]) = ('0', '0')
			elif b > 0:
				if s[l - i - 1] == '?':
					b -= 1
				b -= 1
				(s[i], s[l - i - 1]) = ('1', '1')
	if a > 0 or b > 0 or s != s[::-1]:
		print(-1)
		return
	print(''.join(s))
for t in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	s = list(input())
	n = len(s)
	f = 0
	for i in range(n // 2):
		if s[i] == '?' and s[n - i - 1] == '?':
			continue
		elif s[i] != '?' and s[n - i - 1] != '?':
			if s[i] != s[n - i - 1]:
				f = 1
				break
			elif s[i] == '0':
				a = a - 2
			else:
				b = b - 2
		elif s[i] == '?' and s[n - i - 1] != '?':
			if s[n - i - 1] == '0':
				s[i] = '0'
				a = a - 2
			else:
				s[i] = '1'
				b = b - 2
		elif s[i] != '?' and s[n - i - 1] == '?':
			if s[i] == '0':
				s[n - i - 1] = '0'
				a = a - 2
			else:
				s[n - i - 1] = '1'
				b = b - 2
	if f == 0:
		for i in range(n // 2):
			if s[i] == '?' and s[n - i - 1] == '?':
				if a > b:
					(s[i], s[n - i - 1]) = ('0', '0')
					a = a - 2
				else:
					(s[i], s[n - i - 1]) = ('1', '1')
					b = b - 2
		if n % 2 != 0:
			if s[n // 2] == '0':
				a = a - 1
			elif s[n // 2] == '1':
				b = b - 1
			elif a == 1:
				s[n // 2] = '0'
				a = a - 1
			else:
				s[n // 2] = '1'
				b = b - 1
	if a == 0 and b == 0:
		print(''.join(s))
	else:
		print('-1')


T = int(input())
for ii in range(T):
	(a, b) = map(int, input().split())
	s = [i for i in input()]
	n = a + b
	for i in range(n):
		if s[i] == '?':
			s[i] = s[n - i - 1]
	a -= s.count('0')
	b -= s.count('1')
	i = 0
	j = n - 1
	while i <= j:
		if i != j and s[i] == '?':
			if a > 1:
				s[i] = s[n - i - 1] = '0'
				a -= 2
			elif b > 1:
				s[i] = s[n - i - 1] = '1'
				b -= 2
		elif s[i] == '?':
			if a > 0:
				s[i] = '0'
				a -= 1
			elif b > 0:
				s[i] = '1'
				b -= 1
		i += 1
		j -= 1
	s = ''.join(s)
	if s == s[::-1] and a == b and (a == 0):
		print(s)
	else:
		print(-1)


def spl(a):
	res = []
	for i in a:
		res.append(i)
	return res
for _ in range(int(input())):
	zeros = 0
	ones = 0
	ch = True
	ch1 = True
	ch2 = True
	(a, b) = map(int, input().split())
	l = str(input())
	zoz = spl(l)
	for i in range((a + b) // 2):
		if zoz[i] == '0':
			zeros += 1
		if zoz[i] == '1':
			ones += 1
		if zoz[a + b - 1 - i] == '0':
			zeros += 1
		if zoz[a + b - 1 - i] == '1':
			ones += 1
		if (zoz[i] != '?' and zoz[a + b - 1 - i] != '?') and zoz[i] != zoz[a + b - 1 - i]:
			ch = False
			print(-1)
			break
		if zoz[i] == '?' and zoz[a + b - 1 - i] != '?':
			x = zoz[a + b - 1 - i]
			if x == '0':
				zeros += 1
				zoz[i] = '0'
			else:
				ones += 1
				zoz[i] = '1'
		if zoz[i] != '?' and zoz[a + b - 1 - i] == '?':
			x = zoz[i]
			if x == '0':
				zeros += 1
				zoz[a + b - 1 - i] = '0'
			else:
				ones += 1
				zoz[a + b - i - 1] = '1'
	if ch:
		jed = a - zeros
		dva = b - ones
		for i in range((a + b) // 2):
			if zoz[i] == '?':
				if jed > dva:
					jed -= 2
					zoz[i] = '0'
					zoz[a + b - 1 - i] = '0'
				else:
					dva -= 2
					zoz[i] = '1'
					zoz[a + b - 1 - i] = '1'
			if jed < 0 or dva < 0:
				print(-1)
				ch1 = False
				break
		if ch1:
			if (a + b) % 2 == 1:
				if zoz[(a + b) // 2] == '1':
					dva -= 1
				elif zoz[(a + b) // 2] == '0':
					jed -= 1
				if zoz[(a + b) // 2] != '?':
					if dva != 0 or jed != 0:
						print(-1)
						ch1 = False
				elif jed == 1 and dva == 0:
					zoz[(a + b) // 2] = '0'
				elif jed == 0 and dva == 1:
					zoz[(a + b) // 2] = '1'
				else:
					print(-1)
					ch2 = False
		if ch2 and ch1:
			print(''.join(zoz))


T = int(input())
for t in range(T):
	(Z, O) = map(int, input().split())
	S = list(input())
	F = 0
	if Z * O % 2 == 1:
		print(-1)
		continue
	if Z + O != len(S):
		print(-1)
		continue
	if Z % 2 == 1 and len(S) > 1:
		if S[len(S) // 2] == '?':
			S[len(S) // 2] = '0'
		elif S[len(S) // 2] == '1':
			print(-1)
			continue
	elif O % 2 == 1 and len(S) > 1:
		if S[len(S) // 2] == '?':
			S[len(S) // 2] = '1'
		elif S[len(S) // 2] == '0':
			print(-1)
			continue
	if F == 1:
		continue
	for i in range(len(S)):
		if S[i] != S[-1 - i]:
			if S[i] == '?' and S[-1 - i] == '1':
				S[i] = '1'
			elif S[i] == '?' and S[-1 - i] == '0':
				S[i] = '0'
			elif S[i] == '0' and S[-1 - i] == '1':
				print(-1)
				F = 1
				break
	if F == 1:
		continue
	z = 0
	o = 0
	for i in range(len(S)):
		if S[i] == '0':
			z += 1
		elif S[i] == '1':
			o += 1
	if Z < z or O < o:
		print(-1)
		continue
	for i in range(len(S)):
		if S[i] == '?':
			if Z > z:
				S[i] = '0'
				S[-1 - i] = '0'
				z += 2
			else:
				S[i] = '1'
				S[-1 - i] = '1'
	print(''.join(S))


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
getcontext().prec = 25
MOD = pow(10, 9) + 7
BUFSIZE = 8192
from collections import defaultdict

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(a, b) = map(int, input().split(' '))
	l = list(input())
	if a % 2 and b % 2:
		print(-1)
	elif (a + b) % 2 == 0 and (a % 2 or b % 2):
		print(-1)
	else:
		ans = 'YES'
		c0 = a
		c1 = b
		if (a + b) % 2 and l[(a + b) // 2] == '?':
			if a % 2:
				l[(a + b) // 2] = '0'
				c0 -= 1
			else:
				l[(a + b) // 2] = '1'
				c1 -= 1
		for i in range((a + b) // 2):
			if '1' == l[i] or l[a + b - i - 1] == '1':
				c1 -= 2
			elif l[i] == '0' or l[a + b - i - 1] == '0':
				c0 -= 2
		for i in range((a + b) // 2):
			if l[i] != '?':
				if l[a + b - i - 1] == '?':
					l[a + b - i - 1] = l[i]
				elif l[a + b - i - 1] != l[i]:
					ans = 'NO'
					break
			elif l[a + b - i - 1] != '?':
				if l[i] == '?':
					l[i] = l[a + b - i - 1]
				else:
					ans = 'NO'
					break
			elif l[a + b - i - 1] == '?' and l[i] == '?':
				if c0 > 1:
					l[a + b - i - 1] = l[i] = '0'
					c0 -= 2
				elif c1 > 1:
					l[a + b - i - 1] = l[i] = '1'
					c1 -= 2
		if ans == 'YES':
			if l.count('0') == a and l.count('1') == b:
				for i in range(a + b):
					print(l[i], end='')
				print()
			else:
				print(-1)
		else:
			print(-1)


import sys

def load_sys():
	return sys.stdin.readlines()

def load_local():
	with open('input.txt', 'r') as f:
		input = f.readlines()
	return input

def f(s, a, b):
	n = len(s)
	ans = list(s)
	Q = []
	for i in range(len(s) // 2):
		(c1, c2) = (ans[i], ans[n - i - 1])
		if c1 != '?' and c2 != '?':
			if c1 != c2:
				return -1
			if c1 == '1':
				b -= 2
			else:
				a -= 2
		elif c1 != '?' and c2 == '?':
			if c1 == '1':
				b -= 2
			else:
				a -= 2
			ans[n - i - 1] = c1
		elif c1 == '?' and c2 != '?':
			if c2 == '1':
				b -= 2
			else:
				a -= 2
			ans[i] = c2
		else:
			Q.append(i)
	if n % 2 == 1:
		if ans[n // 2] == '?':
			if b % 2:
				ans[n // 2] = '1'
				b -= 1
			else:
				ans[n // 2] = '0'
				a -= 1
		elif ans[n // 2] == '1':
			b -= 1
		else:
			a -= 1
	if not (a % 2 == 0 and b % 2 == 0):
		return -1
	for i in Q:
		if a > 0:
			(ans[i], ans[n - i - 1]) = ('0', '0')
			a -= 2
		else:
			(ans[i], ans[n - i - 1]) = ('1', '1')
			b -= 2
	if not (a == 0 and b == 0):
		return -1
	return ''.join(ans)
input = load_sys()
for i in range(1, len(input), 2):
	(a, b) = [int(x) for x in input[i].split()]
	s = input[i + 1].strip()
	print(f(s, a, b))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input())
	(i, j) = (0, len(s) - 1)
	while i <= j:
		if s[i] != '?' and s[j] == '?':
			s[j] = s[i]
		elif s[j] != '?' and s[i] == '?':
			s[i] = s[j]
		i += 1
		j -= 1
	a -= s.count('0')
	b -= s.count('1')
	for i in range(0, len(s)):
		j = len(s) - 1 - i
		if i > j:
			break
		if s[i] == '?':
			if a > 1:
				s[i] = '0'
				s[len(s) - 1 - i] = '0'
				a -= 1 + int(i != j)
			elif b > 1:
				s[i] = '1'
				s[len(s) - 1 - i] = '1'
				b -= 1 + int(i != j)
			elif i == j:
				if a > 0:
					s[i] = '0'
					a -= 1
				else:
					s[i] = '1'
					b -= 1
	if a == 0 and b == 0 and (s == list(reversed(s))):
		print(''.join(s))
	else:
		print(-1)


for tt in range(int(input())):
	(a, b) = map(int, input().split())
	n = a + b
	l = list(input())
	cnt = [a, b]
	vis = [0 for i in range(n)]
	for i in range(n):
		if vis[i] == 1:
			continue
		if l[i] != '?':
			cnt[int(l[i])] -= 1
			if l[n - i - 1] == '?':
				vis[n - i - 1] = 1
				l[n - i - 1] = l[i]
				cnt[int(l[i])] -= 1
	for i in range(n // 2):
		if l[i] == '?' or l[n - i - 1] == '?':
			if cnt[0] > 1:
				l[i] = l[n - i - 1] = '0'
				cnt[0] -= 2
			else:
				l[i] = l[n - i - 1] = '1'
				cnt[1] -= 2
		elif l[i] != l[n - i - 1]:
			print(-1)
			break
	else:
		if n % 2 == 1 and l[n // 2] == '?':
			if cnt[0] > 0:
				l[n // 2] = '0'
				cnt[0] -= 1
			else:
				l[n // 2] = '1'
				cnt[1] -= 1
		if cnt == [0, 0]:
			print(''.join(l))
		else:
			print(-1)


tc = int(input())
for _ in range(tc):
	(vertex1, vertex2) = map(int, input().split())
	s = input()
	s = list(s)
	n = vertex1 + vertex2
	for i in range(n // 2):
		if s[i] == '?':
			s[i] = s[n - i - 1]
		elif s[n - i - 1] == '?':
			s[n - i - 1] = s[i]
	vertex1 -= s.count('0')
	vertex2 -= s.count('1')
	for i in range(n // 2):
		if s[i] == '?':
			if vertex1 >= 2:
				s[i] = s[n - i - 1] = '0'
				vertex1 -= 2
			else:
				s[i] = s[n - i - 1] = '1'
				vertex2 -= 2
		elif s[i] != s[n - i - 1]:
			print(-1)
			break
	else:
		if n & 1 and s[n // 2] == '?':
			if vertex1 >= 1:
				s[n // 2] = '0'
				vertex1 -= 1
			else:
				s[n // 2] = '1'
				vertex2 -= 1
		if vertex1 == 0 == vertex2:
			print(''.join(s))
		else:
			print(-1)


def test(zeros, ones, pal):
	pal = list(pal)
	for k in range(len(pal) // 2):
		pair = [pal[k], pal[-k - 1]]
		if '?' not in pair and pair[0] != pair[1]:
			return -1
		if '0' in pair:
			(pal[k], pal[-k - 1]) = ('0', '0')
			zeros -= 2
		elif '1' in pair:
			(pal[k], pal[-k - 1]) = ('1', '1')
			ones -= 2
	if len(pal) % 2 == 1:
		if pal[len(pal) // 2] == '?':
			if zeros % 2 == 1:
				pal[len(pal) // 2] = '0'
			else:
				pal[len(pal) // 2] = '1'
		if pal[len(pal) // 2] == '0':
			zeros -= 1
		elif pal[len(pal) // 2] == '1':
			ones -= 1
	if zeros < 0 or ones < 0 or zeros % 2 == 1:
		return -1
	for k in range(len(pal) // 2):
		pair = [pal[k], pal[-k - 1]]
		if '?' in pair and zeros > 0:
			(pal[k], pal[-k - 1]) = ('0', '0')
			zeros -= 2
		elif '?' in pair:
			(pal[k], pal[-k - 1]) = ('1', '1')
			ones -= 2
	return ''.join(pal)
cases = int(input())
for j in range(cases):
	[zeros, ones] = [int(k) for k in input().split()]
	pal = input()
	print(test(zeros, ones, pal))


def check_palindrome(List):
	oneCount = 0
	zeroCount = 0
	for i in range(len(List) // 2):
		if List[i] != List[-(i + 1)]:
			return False
		elif List[i] == '1' or List[i] == 1:
			oneCount += 2
		else:
			zeroCount += 2
	if len(List) % 2 == 1:
		if List[len(List) // 2] == '1' or List[len(List) // 2] == 1:
			oneCount += 1
		else:
			zeroCount += 1
	if zeroCount <= origMaxZero and oneCount <= origMaxOne:
		return True
	return False

def findNums(daList):
	ones = 0
	twos = 0
	for i in range(len(daList)):
		if daList[i] == '1' or daList[i] == 1:
			ones -= 1
		elif daList[i] == '0' or daList[i] == 0:
			twos -= 1
	return [twos, ones]
numQueries = int(input())
for k in range(numQueries):
	temp = input().split()
	(maxTwo, maxOne) = (int(temp[0]), int(temp[1]))
	origMaxZero = maxTwo
	origMaxOne = maxOne
	daString = input()
	daList = list(daString)
	numQPairs = 0
	numQSingles = 0
	bad = False
	temp = findNums(daList)
	maxTwo += temp[0]
	maxOne += temp[1]
	for i in range(len(daList) // 2 + len(daList) % 2):
		if daList[i] != daList[-(i + 1)] and daList[i] != '?' and (daList[-(i + 1)] != '?'):
			bad = True
			break
		elif daList[i] != '?' and daList[-(i + 1)] == '?':
			daList[-(i + 1)] = daList[i]
			if daList[i] == '1':
				maxOne -= 1
			else:
				maxTwo -= 1
		elif daList[i] == '?' and daList[-(i + 1)] != '?':
			daList[i] = daList[-(i + 1)]
			if daList[i] == '1':
				maxOne -= 1
			else:
				maxTwo -= 1
	alreadyPrinted = False
	if bad == True or maxOne < 0 or maxTwo < 0:
		print(-1)
		alreadyPrinted = True
	else:
		for i in range(len(daList) // 2 + len(daList) % 2):
			if daList[i] == '?':
				if i != len(daList) - i - 1:
					if maxOne > 1:
						daList[i] = '1'
						daList[-(i + 1)] = '1'
						maxOne -= 2
					elif maxTwo > 1:
						daList[i] = '0'
						daList[-(i + 1)] = '0'
						maxTwo -= 2
					else:
						bad = True
				elif maxOne > 0:
					daList[i] = '1'
					maxOne -= 1
				elif maxTwo > 0:
					daList[i] = '0'
					maxTwo -= 1
				else:
					bad = True
	if bad == True and alreadyPrinted == False:
		print(-1)
	elif bad == False:
		if check_palindrome(daList):
			for i in range(len(daList)):
				print(daList[i], end='')
			print()
		elif alreadyPrinted == False:
			print(-1)


def solve():
	(a, b) = map(int, input().split())
	l = list(input().rstrip())
	for i in range(len(l)):
		if l[i] == '?':
			l[i] = l[-1 - i]
		elif l[i] == '0':
			if l[-1 - i] == '1':
				print(-1)
				return
		elif l[i] == '1':
			if l[-1 - i] == '0':
				print(-1)
				return
		if l[i] == '0':
			a -= 1
		elif l[i] == '1':
			b -= 1
	for i in range(len(l)):
		if l[i] == '?':
			if i + i + 1 == len(l):
				if a % 2 == 1:
					l[i] = '0'
					l[-1 - i] = '0'
					a -= 1
				else:
					l[i] = '1'
					l[-1 - i] = '1'
					b -= 1
			elif a >= 2:
				l[i] = '0'
				l[-1 - i] = '0'
				a -= 2
			else:
				l[i] = '1'
				l[-1 - i] = '1'
				b -= 2
	if a < 0 or b < 0:
		print(-1)
		return
	print(''.join(l))
for _ in range(int(input())):
	solve()


def solve():
	(a, b) = list(map(int, input().split()))
	n = a + b
	s = input()
	s = list(s)
	rem = [a, b]
	for i in range(n // 2):
		if s[i] == '?':
			if s[n - i - 1] == '?':
				continue
			else:
				rem[int(s[n - i - 1])] -= 2
				s[i] = s[n - i - 1]
		elif s[n - i - 1] == '?':
			rem[int(s[i])] -= 2
			s[n - i - 1] = s[i]
		elif s[n - i - 1] == s[i]:
			rem[int(s[i])] -= 2
		else:
			print(-1)
			return
	k = 0
	for i in range(n // 2):
		if rem[k] < 2:
			k += 1
		if k == 2:
			break
		if s[i] == '?':
			s[i] = str(k)
			s[n - i - 1] = str(k)
			rem[k] -= 2
	if n % 2 == 1:
		if s[n // 2] == '?':
			if rem[0] > 0:
				s[n // 2] = str(0)
				rem[0] -= 1
			elif rem[1] > 0:
				s[n // 2] = str(1)
				rem[1] -= 1
			else:
				print(-1)
				return
		else:
			rem[int(s[n // 2])] -= 1
	if rem[0] > 0 or rem[1] > 0:
		print(-1)
		return
	print(''.join(s))
t = int(input())
for _ in range(t):
	solve()


import sys
from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	(a, b) = map(int, stdin.readline().split())
	s = list(stdin.readline()[:-1])
	n = a + b
	flag = True
	for i in range(n):
		j = n - 1 - i
		if s[i] == '?' and s[j] != '?':
			s[i] = s[j]
		elif s[i] == '0' and s[j] == '1' or (s[i] == '1' and s[j] == '0'):
			flag = False
			break
	if not flag:
		print(-1)
		continue
	for i in range(n):
		if s[i] == '0':
			a -= 1
		elif s[i] == '1':
			b -= 1
	if a % 2 == 1 and b % 2 == 1 or a < 0 or b < 0:
		print(-1)
		continue
	if a % 2 == 1:
		if n % 2 == 1 and s[n // 2] == '?':
			s[n // 2] = '0'
			a -= 1
		else:
			print(-1)
			continue
	elif b % 2 == 1:
		if n % 2 == 1 and s[n // 2] == '?':
			s[n // 2] = '1'
			b -= 1
		else:
			print(-1)
			continue
	for i in range(n // 2):
		j = n - 1 - i
		if s[i] != '?':
			pass
		elif a > 0:
			s[i] = s[j] = '0'
			a -= 2
		else:
			s[i] = s[j] = '1'
			b -= 2
	print(''.join(s))


def palindrome(S):
	n = len(S)
	f = False
	for i in range(n):
		if S[i] == S[n - i - 1]:
			f = True
	return f
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = input()
	n = a + b
	s = list(s)
	flag = 0
	for i in range(n):
		if s[i] == '?':
			s[i] = s[n - i - 1]
	a -= s.count('0')
	b -= s.count('1')
	for i in range(n // 2 + 1):
		if i != n - i - 1 and s[i] == '?':
			if a > 1:
				s[i] = '0'
				s[n - i - 1] = '0'
				a -= 2
			elif b > 1:
				s[i] = '1'
				s[n - i - 1] = '1'
				b -= 2
		elif s[i] == '?':
			if a > 0:
				s[i] = '0'
				a -= 1
			elif b > 0:
				s[i] = '1'
				b -= 1
	if a == 0 and b == 0 and (s == s[::-1]):
		s = ''.join(s)
		print(s)
	else:
		print('-1')


import sys
input = sys.stdin.readline

def ABpalindrome(a, b, s):
	(d, n) = ({'0': a, '1': b}, a + b)
	if n == 1:
		if a == 1:
			return 0 if s[0] == '0' or s[0] == '?' else -1
		if b == 1:
			return 1 if s[0] == '1' or s[0] == '?' else -1
	if a % 2 and b % 2:
		return -1
	elif a % 2:
		if s[n // 2] == '?':
			s[n // 2] = '0'
		elif s[n // 2] == '1':
			return -1
		d['0'] -= 1
	elif b % 2:
		if s[n // 2] == '?':
			s[n // 2] = '1'
		elif s[n // 2] == '0':
			return -1
		d['1'] -= 1
	for i in range(n // 2):
		if s[i] == s[n - i - 1]:
			if s[i] != '?':
				d[s[i]] -= 2
		elif s[i] == '?' or s[n - i - 1] == '?':
			if s[i] == '?':
				s[i] = s[n - i - 1]
				d[s[n - i - 1]] -= 2
			elif s[n - i - 1] == '?':
				s[n - i - 1] = s[i]
				d[s[i]] -= 2
		else:
			return -1
	for i in range(n // 2):
		if s[i] == '?':
			if d['0'] > 1:
				(s[i], s[n - i - 1]) = ('0', '0')
				d['0'] -= 2
			elif d['1'] > 1:
				(s[i], s[n - i - 1]) = ('1', '1')
				d['1'] -= 2
			else:
				return -1
	if d['0'] != 0 or d['1'] != 0:
		return -1
	return ''.join(s)

def main():
	for t in range(int(input())):
		(a, b) = map(int, input().split())
		s = [ch for ch in input().strip()]
		print(ABpalindrome(a, b, s))
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	s = list(input())
	n = len(s)
	for i in s:
		if i == '1':
			b -= 1
		elif i == '0':
			a -= 1
	if a < 0 or b < 0:
		print(-1)
		continue
	check = True
	for i in range(n // 2):
		if s[i] == '?':
			if s[n - i - 1] == '?':
				continue
			if s[n - i - 1] == '1':
				b -= 1
			else:
				a -= 1
			s[i] = s[n - i - 1]
		elif s[n - i - 1] == '?':
			if s[i] == '1':
				b -= 1
			else:
				a -= 1
			s[n - i - 1] = s[i]
		elif s[i] != s[n - i - 1]:
			check = False
			break
		if a < 0 or b < 0:
			check = False
			break
	if check == False:
		print(-1)
		continue
	for i in range(n // 2):
		if s[i] == '?':
			if a > 1:
				s[i] = '0'
				s[n - i - 1] = '0'
				a -= 2
			elif b > 1:
				s[i] = '1'
				s[n - i - 1] = '1'
				b -= 2
			else:
				check = False
				break
	if check == False:
		print(-1)
		continue
	m = (n + 1) // 2 - 1
	if s[m] == '?':
		if a > 0:
			s[m] = '0'
		else:
			s[m] = '1'
	print(''.join(s))


import sys
input = sys.stdin.readline

def solve():
	(a, b) = map(int, input().split())
	s = list(input().strip())
	n = len(s)
	if a + b != n:
		print(-1)
		return
	c = [0, 0]
	for i in range(n):
		if i < n - 1 - i:
			if s[i] != '?':
				if s[n - 1 - i] != '?':
					if s[i] != s[n - 1 - i]:
						print(-1)
						return
					else:
						c[int(s[i])] += 2
				else:
					c[int(s[i])] += 2
					s[n - 1 - i] = s[i]
			elif s[n - 1 - i] != '?':
				c[int(s[n - 1 - i])] += 2
				s[i] = s[n - 1 - i]
		elif i == n - 1 - i:
			if s[i] != '?':
				c[int(s[i])] += 1
		else:
			break
	a -= c[0]
	b -= c[1]
	for i in range(n):
		if i < n - 1 - i:
			if s[i] == '?':
				if a >= 2:
					a -= 2
					s[i] = '0'
					s[n - i - 1] = '0'
				elif b >= 2:
					b -= 2
					s[i] = '1'
					s[n - i - 1] = '1'
				else:
					print(-1)
					return
		elif i == n - 1 - i:
			if s[i] == '?':
				if a > 0:
					a -= 1
					s[i] = '0'
				elif b > 0:
					b -= 1
					s[i] = '1'
				else:
					print(-1)
					return
		else:
			break
	if a == 0 and b == 0:
		print(''.join(s))
	else:
		print(-1)
for i in range(int(input())):
	solve()


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	s = list(input())
	for i in range(len(s)):
		if s[i] == '?' and s[len(s) - i - 1] != '?':
			k = s[len(s) - i - 1]
			s[i] = k
	a = a - ''.join(s).count('0')
	b = b - ''.join(s).count('1')
	if a < 0 or b < 0:
		print(-1)
	elif a % 2 == 1 and b % 2 == 1:
		print(-1)
	else:
		for i in range(len(s) // 2 + 1):
			if s[i] == '?':
				if a >= 2:
					(s[i], s[len(s) - i - 1]) = ('0', '0')
					a -= 2
					continue
				if b >= 0:
					(s[i], s[len(s) - i - 1]) = ('1', '1')
					b -= 2
					continue
		if a == 1:
			s[len(s) // 2] = '0'
		if b == 1:
			s[len(s) // 2] = '1'
		if ''.join(s) == ''.join(s)[::-1]:
			print(''.join(s))
		else:
			print(-1)