*Chef has recently introduced a [feature], called WA Test Cases, which allows you to see the smallest test case that your WA code has failed in. For example, you can go to any relevant problem in [Practice], make a submission which gets a WA verdict, and then click on the "Debug My Code" button to see the test case.*

Your job now is to find that smallest test case that a particular submission fails on. That problem has N test cases, and you are given the size of each of those test cases as S_{1}, S_{2}, \ldots, S_{N}. You are also given a binary string V, which tells whether the submission has passed a particular test case or not. That is, if the i^{th} bit of V is 1, that means that the submission has passed the i^{th} test case. If it is 0, then it has failed that test case. Your job is the output the size of the smallest test case where the submission has failed.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains a single integer, N.
- The second line contains N integers - S_{1}, S_{2}, \ldots, S_{N}
- The third line contains a binary string - V.

------ Output Format ------ 

For each test case, output on a new line, a single integer, which should be the size of the smallest test case where the submission has failed.

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ N ≤ 100$
$1 ≤ S_{i} ≤ 100$
- Length of $V = N$
- Each element of $V$ is either $0$ or $1$
- At least one element of $V$ will be $0$

------ subtasks ------ 

Subtask 1 (10 points): $1 ≤ M ≤ 10$
Subtask 2 (20 points): The sum of $N$ across all test cases won't exceed $20$.
Subtask 3 (70 points): No further constraints.

----- Sample Input 1 ------ 
5
3
5 10 3
000
3
5 10 3
001
3
5 5 3
001
3
5 5 3
101
5
10 100 100 10 10
00001

----- Sample Output 1 ------ 
3
5
5
5
10

----- explanation 1 ------ 
Test case 1: There are $3$ test cases, and the submission has failed all the $3$ test cases. The sizes of the test cases on which it has failed are $\{5, 10, 3\}$. The smallest among these is $3$, and so the answer is $3$.

Test case 2: There are $3$ test cases, and the submission has failed on $2$ test cases. The sizes of the test cases on which it has failed are $\{5, 10\}$. The smallest among these is $5$, and so the answer is $5$.

Test case 3: There are $3$ test cases, and the submission has failed on $2$ test cases. The sizes of the test cases on which it has failed are $\{5, 5\}$. The smallest among these is $5$, and so the answer is $5$.

Test case 4: There are $3$ test cases, and the submission has failed on $1$ test case. The sizes of the test case on which it has failed is $\{5\}$. The smallest among these is $5$, and so the answer is $5$.

Test case 5: There are $5$ test cases, and the submission has failed on $4$ test cases. The sizes of the test cases on which it has failed are $\{10, 100, 100, 10\}$. The smallest among these is $10$, and so the answer is $10$.

Source: codechef | Difficulty: EASY


Solutions:
for _testcase in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = input()
	x = []
	for i in range(n):
		if b[i] == '0':
			x.append(a[i])
	print(min(x))


T = int(input())
for _ in range(T):
	N = int(input())
	S = list(map(int, input().split()))
	V = input()
	D = []
	for i in range(N):
		if '0' in V[i]:
			D.append(S[i])
	print(min(D))


for t in range(int(input())):
	testcases = int(input())
	size = tuple(map(int, input().split()))[:testcases]
	result = input()
	MIN = []
	for i in range(testcases):
		if result[i] == '0':
			MIN.append(size[i])
	print(min(MIN))


for i in range(int(input())):
	N = int(input())
	S = list(map(int, input().split()))
	V = input()
	l = []
	for x in range(N):
		if V[x] == '0':
			l.append(S[x])
	print(min(l))


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	v = list(map(int, input()))
	k = []
	for i in range(n):
		if v[i] == 0:
			k.append(s[i])
	print(min(k))


t = int(input())
for i in range(t):
	n = int(input())
	a = input().split()
	s = input()
	lst = []
	for j in range(n):
		if s[j] == '0':
			lst.append(int(a[j]))
	lst.sort()
	print(lst[0])


t = int(input())
for i in range(t):
	x = int(input())
	s = list(map(int, input().split()))
	d = input()
	l1 = []
	for i in range(x):
		if d[i] == '0':
			l1.append(s[i])
	print(min(l1))


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	v = input()
	x = 0
	l = []
	while x < n:
		if int(v[x]) == 0:
			l.append(s[x])
			x += 1
		else:
			x += 1
	print(min(l))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	binn = input()
	p = []
	p1 = 0
	p2 = 0
	for j in range(len(l)):
		if binn[j] == '0':
			p.append(l[j])
	print(min(p))


for _ in range(int(input())):
	t = int(input())
	l = list(map(int, input().split()))
	s = input()
	l1 = []
	for i in range(t):
		if l[i] * int(s[i]) == 0:
			l1.append(l[i])
	print(min(l1))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	v = input()
	s = []
	for i in range(len(v)):
		if v[i] == '0':
			s.append(l[i])
	print(min(s))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = input()
	m = 100
	for i in range(n):
		if s[i] == '0':
			m = min(m, a[i])
	print(m)


n = int(input())
for i in range(n):
	m = int(input())
	m1 = list(map(int, input().split()))
	m2 = list(input())
	lst1 = []
	for j in range(m):
		if m2[j] == '0':
			lst1.append(m1[j])
	print(min(lst1))


t = int(input())
for i in range(t):
	n = int(input())
	list1 = list(map(int, input().split()))
	string1 = input()
	result = []
	for j in range(len(string1)):
		if string1[j] == '0':
			result.append(list1[j])
	print(min(result))


t = int(input())
for i in range(t):
	N = int(input())
	l = map(int, input().split())
	l = list(l)
	V = list(input())
	ind = 0
	ll = []
	while ind < N:
		if V[ind] == '0':
			ll.append(l[ind])
		ind += 1
	print(min(ll))


t = int(input())
for ele in range(t):
	a = int(input())
	s = list(map(int, input().split()))
	v = input()
	b = []
	for i in range(a):
		if v[i] == '0':
			b.append(s[i])
	print(min(b))


for _ in range(int(input())):
	a1 = []
	n = int(input())
	a = list(map(int, input().split()))
	b = [i for i in input()]
	for i in range(n):
		if b[i] == '0':
			a1.append(a[i])
	print(min(a1))


t = int(input())
for i in range(t):
	a = int(input())
	b = [int(b) for b in input().split()]
	c = [int(c) for c in input().strip()]
	d = []
	for i in range(a):
		if c[i] == 0:
			d.append(b[i])
	print(min(d))


T = int(input())
for _ in range(T):
	N = int(input())
	S = map(int, input().split())
	V = input()
	print(min([i for (i, j) in zip(S, V) if j == '0']))


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = input()
	c = []
	for i in range(n):
		if b[i] == '0':
			c.append(a[i])
	print(min(c))


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	v = input().strip()
	zeros = v.count('0')
	if zeros == 0:
		print(min(s))
	else:
		zero_indices = [j for j in range(n) if v[j] == '0']
		min_val = min([s[j] for j in zero_indices])
		print(min_val)


for i in range(int(input())):
	n = int(input())
	s = list(input().split())
	v = input()
	lst = []
	lst1 = []
	for i in range(n):
		lst.append(v[i])
	for i in range(n):
		if int(lst[i]) == 0:
			lst1.append(int(s[i]))
	print(min(lst1))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	b = input()
	l2 = []
	for i in range(n):
		if b[i] == '0':
			l2.append(l[i])
	print(min(l2))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = input()
	c = []
	for i in range(n):
		z = int(b[i])
		if z == 0:
			c.append(a[i])
	print(min(c))


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	v = list(map(int, input().strip()))
	m = max(s)
	for i in range(0, len(v)):
		if v[i] == 0:
			if m > s[i]:
				m = s[i]
	print(m)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	v = input()
	smallest = 1000
	for i in range(len(arr)):
		if v[i] == '0':
			if arr[i] < smallest:
				smallest = arr[i]
	print(smallest)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	b = input()
	x = []
	for j in range(n):
		if b[j] == '0':
			x.append(s[j])
	print(min(x))


t = int(input())
for j in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	v = input()
	l = []
	for i in range(n):
		if v[i] == '0':
			l.append(l1[i])
	print(min(l))


t = int(input())
for _ in range(t):
	n = int(input())
	s = [int(x) for x in input().split()]
	v = input()
	f = []
	for i in range(n):
		if v[i] == '0':
			f.append(s[i])
	print(min(f))


t = int(input())
for i in range(t):
	n = int(input())
	S = list(map(int, input().split()))
	v = input()
	small = []
	for j in range(n):
		if v[j] == '0':
			small.append(S[j])
	print(min(small))


for _ in range(int(input())):
	a = int(input())
	s = list(map(int, input().split()))
	n = input()
	c = []
	for i in range(0, a):
		if n[i] == '0':
			c.append(s[i])
		else:
			continue
	print(min(c))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	v = input()
	b = []
	for i in range(n):
		if v[i] == '0':
			b.append(a[i])
	b.sort()
	print(b[0])


for i in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = []
	k = str(input())
	for j in range(n):
		if k[j] == '0':
			l2.append(l1[j])
	print(min(l2))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = str(input())
	z = []
	for i in range(len(a)):
		if b[i] == '0':
			z.append(a[i])
		else:
			pass
	print(min(z))


t = int(input())
for i in range(0, t):
	n = int(input())
	lst1 = list(map(int, input().split()))
	x = str(input())
	lst = []
	for j in range(n):
		if x[j] == '0':
			lst.append(lst1[j])
	print(min(lst))


Test = int(input())
for Cases in range(Test):
	Problems = int(input())
	Submission = list(map(int, input().split()))
	BinaryString = input()
	SubmissionValues = []
	for Values in range(Problems):
		if BinaryString[Values] == '0':
			SubmissionValues.append(Submission[Values])
	print(min(SubmissionValues))


def submission_failed(s, v, n):
	x = []
	for i in range(n):
		if v[i] == '0':
			x.append(s[i])
	y = min(x)
	return y
for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().strip().split()))[:n]
	v = input()
	print(submission_failed(s, v, n))


t = int(input())
while t > 0:
	n = int(input())
	s = list(map(int, input().split()))
	v = input()
	min = 101
	i = 0
	for i in range(len(s)):
		if s[i] < min and v[i] == '0':
			min = s[i]
	print(min)
	t -= 1


for _ in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	v = input()
	l1 = []
	for i in range(a):
		if v[i] == '0':
			l1.append(l[i])
	print(min(l1))


for i in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	v = str(input())
	x = []
	for i in range(n):
		if v[i] == '0':
			x.append(s[i])
	print(min(x))


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	b = [int(i) for i in input()]
	mn = max(l)
	for i in range(n):
		if b[i] == 0 and l[i] < mn:
			mn = l[i]
	print(mn)


for i in range(int(input())):
	n = int(input())
	numbers = list(map(int, input().split(' ')))
	string = str(input())
	mini = 100000
	for i in range(n):
		if string[i] == '0':
			if mini > numbers[i]:
				mini = numbers[i]
	print(mini)


t = int(input())
for i in range(0, t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	m = input()
	max = 1000000
	for i in range(0, n):
		if m[i] == '0' and l[i] <= max:
			max = l[i]
	print(max)


for _ in range(int(input())):
	n = int(input())
	List = list(map(int, input().split()))
	List1 = []
	bstring = input(' ')
	bstringlen = len(str(bstring))
	for (binary_digit, list_element) in zip(bstring, List):
		if binary_digit == '0':
			List1.append(list_element)
	print(min(List1))


for _ in range(int(input())):
	c = int(input())
	l = list(map(int, input().split()))
	a = input()
	y = []
	for i in range(len(l)):
		if a[i] == '0':
			y.append(l[i])
	print(min(y))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = input()
	k = []
	for j in range(0, n):
		if s[j] == '0':
			k.append(l[j])
	s = sorted(k)
	print(s[0])


for i in range(int(input())):
	n = int(input())
	lis1 = list(map(int, input().split()))
	t = input()
	lis2 = [(j, i) for (i, j) in zip(t, lis1)]
	lis2.sort()
	for (j, i) in lis2:
		if i == '0':
			print(j)
			break


n = int(input())
for _ in range(n):
	x = int(input())
	l = list(map(int, input().split()))
	s = input()
	b = []
	for i in range(x):
		if s[i] == '0':
			b.append(l[i])
	print(min(b))


for t in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = input()
	d = []
	e = []
	for i in c:
		d.append(i)
	for i in range(len(b)):
		if d[i] == '0':
			e.append(b[i])
	print(min(e))


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	v = input()
	res = float('inf')
	for i in range(len(s)):
		if v[i] == '0':
			res = min(res, s[i])
	print(res)


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))[:n]
	v = input()
	ans = max(s)
	for i in range(n):
		if v[i] == '0':
			if ans > s[i]:
				ans = s[i]
	print(ans)


for _ in range(int(input())):
	n = int(input())
	x = map(int, input().split())
	y = input()
	z = []
	for (i, j) in zip(x, y):
		if j == '0':
			z.append(i)
	print(min(z))


for _ in range(int(input())):
	n = int(input())
	S = list(map(int, input().split()))
	V = list(map(int, input().strip()))
	minValue = max(S)
	for i in range(0, len(V)):
		if V[i] == 0:
			if minValue > S[i]:
				minValue = S[i]
	print(minValue)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = input()
	r = []
	for i in range(len(a)):
		if s[i] == '0':
			r.append(a[i])
	print(min(r))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = input()
	l2 = []
	for i in range(n):
		if s[i] == '0':
			l2.append(l[i])
	l2.sort()
	print(l2[0])


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = input()
	a = []
	c = 0
	for i in s:
		if i == '0':
			a.append(l[c])
		c = c + 1
	print(min(a))


t = int(input())
for i in range(t):
	a = int(input())
	b = list(map(int, input().split()))
	c = input()
	x = []
	for i in range(a):
		if c[i] == '0':
			x.append(b[i])
	print(min(x))


for _ in range(int(input())):
	x = int(input())
	list1 = list(map(int, input().split()))
	string = input()
	array = []
	ans = []
	for i in string:
		i = int(i)
		array.append(i)
	for j in range(x):
		if array[j] == 0:
			ans.append(list1[j])
		else:
			pass
	print(min(ans))