You are given four integers $n$, $c_0$, $c_1$ and $h$ and a binary string $s$ of length $n$.

A binary string is a string consisting of characters $0$ and $1$.

You can change any character of the string $s$ (the string should be still binary after the change). You should pay $h$ coins for each change.

After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character $0$ you should pay $c_0$ coins, to buy the character $1$ you should pay $c_1$ coins.

Find the minimum number of coins needed to buy the string.


-----Input-----

The first line contains a single integer $t$ ($1 \leq t \leq 10$) — the number of test cases. Next $2t$ lines contain descriptions of test cases.

The first line of the description of each test case contains four integers $n$, $c_{0}$, $c_{1}$, $h$ ($1 \leq n, c_{0}, c_{1}, h \leq 1000$).

The second line of the description of each test case contains the binary string $s$ of length $n$.


-----Output-----

For each test case print a single integer — the minimum number of coins needed to buy the string.


-----Examples-----

Input
6
3 1 1 1
100
5 10 100 1
01010
5 10 1 1
11111
5 1 10 1
11111
12 2 1 10
101110110101
2 100 1 10
00
Output
3
52
5
10
16
22


-----Note-----

In the first test case, you can buy all characters and pay $3$ coins, because both characters $0$ and $1$ costs $1$ coin.

In the second test case, you can firstly change $2$-nd and $4$-th symbols of the string from $1$ to $0$ and pay $2$ coins for that. Your string will be $00000$. After that, you can buy the string and pay $5 \cdot 10 = 50$ coins for that. The total number of coins paid will be $2 + 50 = 52$.

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Implementation


Solutions:
t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	print(min(n * c0 + h * s.count('1'), n * c1 + h * s.count('0'), c0 * s.count('0') + c1 * s.count('1')))


for t in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	ze = s.count('0')
	on = s.count('1')
	noch = ze * c0 + on * c1
	ch1 = ze * h + n * c1
	ch2 = on * h + n * c0
	print(min(noch, ch1, ch2))


t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	total = 0
	count0 = s.count('0')
	count1 = s.count('1')
	if c1 > c0 + h:
		s = s.replace('1', '0')
		total = total + h * count1
	elif c0 > c1 + h:
		s = s.replace('0', '1')
		total = total + h * count0
	count0 = s.count('0')
	count1 = s.count('1')
	total = total + count0 * c0 + count1 * c1
	print(total)


import sys

def greedyCalc(n, c0, c1, h, binInput):
	totalCost = 0
	for c in binInput:
		if c == '0':
			curCost = c0
			changedCost = c1 + h
		else:
			curCost = c1
			changedCost = c0 + h
		if changedCost < curCost:
			totalCost = totalCost + changedCost
		else:
			totalCost = totalCost + curCost
	return totalCost
testcase_flag = True
count = 0
testCaseCount = 0
costs = []
for line in sys.stdin:
	inputs = [x for x in line.strip().split()]
	if testcase_flag:
		testCaseCount = int(inputs[0])
		testcase_flag = False
		continue
	if count % 2 == 0:
		n = int(inputs[0])
		c0 = int(inputs[1])
		c1 = int(inputs[2])
		h = int(inputs[3])
		count = count + 1
		continue
	if count % 2 == 1:
		binaryInput = inputs[0]
		count = count + 1
		cost = greedyCalc(n, c0, c1, h, binaryInput)
		costs.append(cost)
		if count == testCaseCount * 2:
			break
for i in range(testCaseCount):
	print(costs[i])


import math

def buy_the_string():
	t = int(input())
	for _ in range(t):
		(n, c0, c1, h) = [int(x) for x in input().split(' ')]
		binary_str = input()
		sum_str = 0
		for x in binary_str:
			if x == '1':
				sum_str += min(c1, c0 + h)
			else:
				sum_str += min(c0, c1 + h)
		print(sum_str)
buy_the_string()


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	(n, c0, c1, h) = map(int, stdin.readline().split())
	s = stdin.readline()[:-1]
	co0 = 0
	co1 = 0
	for i in s:
		if i == '0':
			co0 += 1
	co1 = n - co0
	if c0 > c1:
		cost = co0 * c0 + co1 * c1
		minco = cost
		for j in range(1, co0 + 1):
			cost += h - c0 + c1
			if cost < minco:
				minco = cost
			else:
				break
		print(minco)
	else:
		cost = co0 * c0 + co1 * c1
		minco = cost
		for j in range(1, co1 + 1):
			cost += h - c1 + c0
			if cost < minco:
				minco = cost
			else:
				break
		print(minco)


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, a, b, h) = map(int, input().split())
	s = input()[:-1]
	x = s.count('0')
	y = s.count('1')
	ans = float('inf')
	if a > b:
		(a, b) = (b, a)
		(x, y) = (y, x)
	for i in range(0, y + 1):
		ans = min(ans, (x + i) * a + (y - i) * b + i * h)
	print(ans)


import sys
import sys
import 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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
T = int(input())
for _ in range(T):
	(n, c0, c1, change) = map(int, input().split())
	s = list(input())
	(zero, one) = (0, 0)
	for ch in s:
		zero += ch == '0'
		one += ch == '1'
	ans = zero * c0 + one * c1
	ans = min(ans, c1 * n + zero * change)
	ans = min(ans, c0 * n + one * change)
	print(ans)


t = int(input())
for _ in range(t):
	sum = 0
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	for i in range(len(s)):
		if s[i] == '0':
			if h + c1 < c0:
				sum += h + c1
			else:
				sum += c0
		elif h + c0 < c1:
			sum += h + c0
		else:
			sum += c1
	print(sum)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	ans = 0
	for i in range(n):
		if int(s[i]) == 0:
			if c0 > h + c1:
				ans += h + c1
			else:
				ans += c0
		if int(s[i]) == 1:
			if c1 > h + c0:
				ans += h + c0
			else:
				ans += c1
	print(ans)


tests = int(input())
for test in range(tests):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	count_0 = s.count('0')
	count_1 = s.count('1')
	print(min(c0 * count_0 + c1 * count_1, count_0 * h + n * c1, count_1 * h + n * c0))


for _ in range(int(input())):
	(n, co, cl, h) = map(int, input().split())
	s = input()
	zeros = 0
	ones = 0
	for i in s:
		if i == '0':
			zeros += 1
		else:
			ones += 1
	ans = min(n * co + h * ones, n * cl + h * zeros, zeros * co + ones * cl)
	print(ans)


t = int(input())
for i in range(t):
	temp = [int(x) for x in input().split()]
	n = temp[0]
	c0 = temp[1]
	c1 = temp[2]
	h = temp[3]
	s = input()
	if min(c0, c1) + h < max(c0, c1):
		if c0 < c1:
			print(h * s.count('1') + n * c0)
		else:
			print(h * s.count('0') + n * c1)
	else:
		x = s.count('0')
		print(c0 * x + c1 * (n - x))


for test in range(int(input())):
	(n, c0, c1, h) = list(map(int, input().split()))
	s = input()
	pay = 0
	for i in range(n):
		if s[i] == '1':
			pay += min(c1, c0 + h)
		else:
			pay += min(c0, c1 + h)
	print(pay)


def buy(n, c0, c1, h, s):
	if c0 + h < c1:
		cost1 = c0 + h
	else:
		cost1 = c1
	if c1 + h < c0:
		cost0 = c1 + h
	else:
		cost0 = c0
	price = 0
	for i in s:
		if i == '0':
			price += cost0
		else:
			price += cost1
	return price
t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	print(buy(n, c0, c1, h, s))


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	st = input()
	zero = st.count('0')
	one = n - zero
	lis = [zero * c0 + one * c1, (zero + one) * c0 + one * h, zero * h + (zero + one) * c1]
	print(min(lis))


t = int(input())
while t:
	t = t - 1
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	ones = s.count('1')
	zeros = n - ones
	print(min(zeros * c0 + ones * c1, c1 * n + h * zeros, c0 * n + h * ones))


for _ in range(int(input())):
	(n, z, o, h) = map(int, input().split())
	s = input()
	zero = s.count('0')
	one = n - zero
	if o == z:
		print(o * one + zero * z)
	else:
		print(min(n * z + one * h, o * n + zero * h, one * o + zero * z))


for i in range(int(input())):
	(n, z, o, h) = [int(i) for i in input().split()]
	s = input()
	zero = s.count('0')
	one = s.count('1')
	ans = 0
	if z < o:
		if one * h + one * z < one * o:
			zero += one
			ans += one * h
			one = 0
	elif o < z:
		if zero * h + zero * o < zero * z:
			one += zero
			ans += zero * h
			zero = 0
	ans += zero * z + one * o
	print(ans)


def solve():
	(n, c0, c1, h) = [int(x) for x in input().split()]
	s = input()
	(zero, one) = (0, 0)
	for letter in s:
		if letter == '0':
			zero += 1
		else:
			one += 1
	cost_zero = h * one + c0 * n
	cost_one = h * zero + c1 * n
	cost = c1 * one + c0 * zero
	print(min([cost_one, cost_zero, cost]))
l = int(input())
while l > 0:
	solve()
	l -= 1


t = int(input())
for _ in range(t):
	(n, a, b, h) = [int(x) for x in input().split()]
	s = input()
	c = s.count('0')
	d = n - c
	ans = 0
	if c * a <= c * h + c * b:
		ans += c * a
	else:
		ans += c * h + c * b
	if d * b <= d * h + d * a:
		ans += d * b
	else:
		ans += d * h + d * a
	print(ans)


for i in range(int(input())):
	(n, a, b, k) = map(int, input().split())
	s = input()
	s2 = s.count('1')
	s1 = s.count('0')
	print(min(min((a + k) * s2 + a * s1, (b + k) * s1 + b * s2), a * s1 + b * s2))


def buy_string(listOfNum, string):
	zeroCount = 0
	oneCount = 0
	for i in range(listOfNum[0]):
		if string[i] == '0':
			zeroCount += 1
		else:
			oneCount += 1
	cost = zeroCount * listOfNum[1] + oneCount * listOfNum[2]
	if listOfNum[1] + listOfNum[3] < listOfNum[2]:
		cost -= oneCount * (listOfNum[2] - listOfNum[1] - listOfNum[3])
	if listOfNum[2] + listOfNum[3] < listOfNum[1]:
		cost -= zeroCount * (listOfNum[1] - listOfNum[2] - listOfNum[3])
	print(cost)
numCases = int(input(''))
for i in range(numCases):
	tempList = input('').split(' ')
	tempList = [int(x) for x in tempList]
	tempString = input('')
	buy_string(tempList, tempString)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	count0 = s.count('0')
	count1 = n - count0
	ans = min(count0 * c0 + count1 * c1, n * c0 + h * count1, n * c1 + h * count0)
	print(ans)


PI = 3.141592653589793
INF = 999999999
MOD = 1000000007
import random

def add(x, y):
	return (x + y) % MOD

def sub(x, y):
	return (x - y + MOD) % MOD

def mul(x, y):
	return x * y % MOD

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def power(x, y):
	res = 1
	x %= MOD
	while y != 0:
		if y & 1:
			res = mul(res, x)
		y >>= 1
		x = mul(x, x)
	return res

def mod_inv(n):
	return power(n, MOD - 2)

def prob(p, q):
	return mul(p, power(q, MOD - 2))

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

def li():
	return [int(i) for i in input().split()]

def ls():
	return [i for i in input().split()]
for t in range(ii()):
	(n, c0, c1, h) = li()
	s = input()
	zer = s.count('0')
	on = s.count('1')
	print(min(c0 * zer + c1 * on, n * c0 + h * on, n * c1 + h * zer))


t = int(input())
for gg in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	aq1 = 0
	aq0 = 0
	otv = 0
	if c0 + h < c1:
		aq1 = c0 + h
	else:
		aq1 = c1
	if c1 + h < c0:
		aq0 = c1 + h
	else:
		aq0 = c0
	for i in range(n):
		if list(s)[i] == '1':
			otv += aq1
		else:
			otv += aq0
	print(otv)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	zeros = 0
	ones = 0
	for i in s:
		if i == '0':
			zeros += 1
		else:
			ones += 1
	print(ones * min(c1, c0 + h) + zeros * min(c0, c1 + h))


def panda(s, n, c0, c1, h):
	(z, o) = (0, 0)
	for i in s:
		if i == '1':
			o += 1
		else:
			z += 1
	ct = z * c0 + o * c1
	return min(ct, n * c0 + o * h, c1 * n + z * h)
for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	print(panda(s, n, c0, c1, h))


t = int(input())
for i in range(t):
	s = list(map(int, input().split(' ')))
	n = s[0]
	c0 = s[1]
	c1 = s[2]
	h = s[3]
	b = input()
	b0 = 0
	b1 = 0
	for c in b:
		if c == '0':
			b0 += 1
		else:
			b1 += 1
	c = 0
	if abs(c0 - c1) <= h:
		c = c0 * b0 + c1 * b1
	elif c0 > c1:
		c = b0 * h + n * c1
	else:
		c = n * c0 + b1 * h
	print(c)


import sys
import bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

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

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 9
	n = random.randint(1, N)
	m = random.randint(1, n * n)
	A = [random.randint(1, n) for i in range(m)]
	B = [random.randint(1, n) for i in range(m)]
	G = [[] for i in range(n)]
	RG = [[] for i in range(n)]
	for i in range(m):
		(a, b) = (A[i] - 1, B[i] - 1)
		if a == b:
			continue
		G[a] += ((b, 1),)
		RG[b] += ((a, 1),)
	return (n, m, G, RG)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 == a2:
			print(inp)
			print('naive', a1)
			print('solve', a2)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

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

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()

class Comb:

	def __init__(self, n, mo=10 ** 9 + 7):
		self.fac = [0] * (n + 1)
		self.inv = [1] * (n + 1)
		self.fac[0] = 1
		self.fact(n)
		for i in range(1, n + 1):
			self.fac[i] = i * self.fac[i - 1] % mo
			self.inv[n] *= i
			self.inv[n] %= mo
		self.inv[n] = pow(self.inv[n], mo - 2, mo)
		for i in range(1, n):
			self.inv[n - i] = self.inv[n - i + 1] * (n - i + 1) % mo
		return

	def fact(self, n):
		return self.fac[n]

	def invf(self, n):
		return self.inv[n]

	def comb(self, x, y):
		if y < 0 or y > x:
			return 0
		return self.fac[x] * self.inv[x - y] * self.inv[y] % mo
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	(n, c0, c1, h) = LI()
	s = input()
	n0 = s.count('0')
	n1 = s.count('1')
	if c0 > c1 + h:
		c0 = c1 + h
	elif c0 + h < c1:
		c1 = c0 + h
	else:
		0
	ans = c0 * n0 + c1 * n1
	print(ans)


T = input()
T = int(T)
for rep in range(0, T):
	(n, c0, c1, h) = input().split()
	n = int(n)
	c0 = int(c0)
	c1 = int(c1)
	h = int(h)
	s = input()
	ones = 0
	zeros = 0
	for i in range(0, n):
		if s[i] == '0':
			zeros = zeros + 1
		else:
			ones = ones + 1
	if c0 < c1 and h + c0 < c1:
		print(h * ones + c0 * n)
	elif c1 < c0 and h + c1 < c0:
		print(h * zeros + c1 * n)
	else:
		print(c0 * zeros + c1 * ones)


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = [int(x) for x in input().split()]
	s = list(input())
	x1 = s.count('1')
	x0 = s.count('0')
	a = c0 * x0 + c1 * x1
	a = min(a, c0 * n + h * x1, c1 * n + h * x0)
	print(a)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	flag = 0
	if h + c0 < c1:
		flag = -1
	elif h + c1 < c0:
		flag = 1
	else:
		flag = 0
	z = s.count('0')
	o = s.count('1')
	if flag == 1:
		print(o * c1 + z * (h + c1))
	elif flag == -1:
		print(z * c0 + o * (h + c0))
	else:
		print(z * c0 + o * c1)


t = int(input())
for inh in range(0, t):
	(n, a, b, h) = map(int, input().split())
	s = input()
	zer = s.count('0')
	one = s.count('1')
	if a == b:
		print(n * a)
	elif a < b:
		if a + h < b:
			print(a * n + h * one)
		else:
			print(a * zer + b * one)
	elif b + h < a:
		print(b * n + h * zer)
	else:
		print(b * one + a * zer)


import math
import os
import random
import re
import string
from sys import *
from collections import *

def bs(arr, x, l, r):
	if l <= r:
		mid = (r + l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return bs(arr, x, l, mid - 1)
		else:
			return bs(arr, x, mid + 1, r)
	else:
		return -1

def solve():
	for _ in range(int(input())):
		(n, c0, c1, h) = map(int, stdin.readline().strip().split())
		l = list(input())
		r0 = l.count('0')
		r1 = l.count('1')
		h0 = h * r0
		h1 = h * r1
		co1 = r1 * c1 + r0 * c0
		co2 = h0 + c1 * len(l)
		co3 = h1 + c0 * len(l)
		print(min(co1, co2, co3))
solve()


t = int(input())
for _ in range(t):
	c = [-1, -1]
	(n, c[0], c[1], h) = map(int, input().split())
	s = input()
	ans = 0
	for i in s:
		ans += min(c[int(i)], c[1 - int(i)] + h)
	print(ans)


try:
	for _ in range(int(input())):
		(n, c0, c1, h) = map(int, input().split())
		arr = input()
		count0 = arr.count('0')
		count1 = arr.count('1')
		arr = list(arr)
		ans = min(count0 * c0 + count1 * c1, count0 * h + n * c1, count1 * h + n * c0)
		print(ans)
except:
	pass


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, c0, c1, h) = value()
	s = input()
	one = s.count('1')
	zero = s.count('0')
	res = inf
	for i in range(n + 1):
		here1 = i
		here0 = n - i
		ans = here0 * c0 + here1 * c1
		if here0 > zero:
			ans += (here0 - zero) * h
		elif here1 > one:
			ans += (here1 - one) * h
		res = min(ans, res)
	print(res)


def solve(n, c0, c1, h, s):
	zeros = 0
	ones = 0
	cost1 = c0 * s.count('0') + c1 * s.count('1')
	count = 0
	for i in range(n):
		if s[i] == '1':
			count += 1
	cost2 = c0 * len(s) + count * h
	count2 = 0
	for i in range(n):
		if s[i] == '0':
			count2 += 1
	cost3 = c1 * len(s) + count2 * h
	return min(cost1, cost2, cost3)
t = int(input())
while t:
	(n, c0, c1, h) = map(int, input().split())
	num = input()
	print(solve(n, c0, c1, h, num))
	t -= 1


def solve():
	(n, c0, c1, h) = map(int, input().split())
	string = input()
	zeros = string.count('0')
	ones = string.count('1')
	ans = zeros * c0 + ones * c1
	if c0 >= c1:
		ans = min(ans, h * zeros + c1 * n)
	else:
		ans = min(ans, h * ones + c0 * n)
	print(ans)
t = int(input())
while t:
	solve()
	t -= 1


t = int(input())
while t:
	(n, c0, c1, h) = map(int, input().split())
	word = input()
	if c0 == c1:
		print(c0 * n)
		t -= 1
		continue
	(n0, n1) = (0, 0)
	for i in word:
		if i == '0':
			n0 += 1
		else:
			n1 += 1
	if c0 > c1 and h < c0 - c1:
		print(c1 * n + n0 * h)
	elif c1 > c0 and h < c1 - c0:
		print(c0 * n + n1 * h)
	else:
		print(c0 * n0 + c1 * n1)
	t -= 1


for _ in range(0, int(input())):
	(n, c0, c1, h) = map(int, input().split())
	d = {}
	d['0'] = [c0, 0]
	d['1'] = [c1, 0]
	t = 0
	i = sorted(d, key=d.get)
	c = input().count('0')
	d['0'][1] = c
	d['1'][1] = n - c
	(a, b) = i
	t += d[a][0] * d[a][1]
	if d[b][0] > h + d[a][0]:
		t += (h + d[a][0]) * d[b][1]
	else:
		t += d[b][0] * d[b][1]
	print(t)


import math
inf = float('inf')
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = list(input())
	ans = 0
	if c0 < c1 and h < abs(c1 - c0):
		for i in range(n):
			if s[i] == '1':
				s[i] = '0'
				ans += h
	elif c0 > c1 and h < abs(c1 - c0):
		for i in range(n):
			if s[i] == '0':
				s[i] = '1'
				ans += h
	for i in s:
		if i == '1':
			ans += c1
		else:
			ans += c0
	print(ans)


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = list(map(int, input().split()))
	s = input()
	(ct1, ct0) = (s.count('1'), s.count('0'))
	if c0 > c1:
		if c0 > c1 + h:
			ans = (c1 + h) * ct0 + c1 * ct1
		else:
			ans = c0 * ct0 + c1 * ct1
	elif c1 > c0 + h:
		ans = (c0 + h) * ct1 + ct0 * c0
	else:
		ans = c0 * ct0 + c1 * ct1
	print(ans)


t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	ans = 0
	for i in s:
		if i == '0':
			ans += min(c0, c1 + h)
		else:
			ans += min(c1, c0 + h)
	print(ans)


from sys import stdin, stdout
import math
from collections import deque

def solve():
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	(cnt0, cnt1) = (s.count('0'), s.count('1'))
	if c0 == c1:
		print(n * c0)
	elif c0 + h < c1:
		print(h * cnt1 + n * c0)
	elif c1 + h < c0:
		print(h * cnt0 + n * c1)
	else:
		print(cnt1 * c1 + cnt0 * c0)
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


t = int(input())
while t > 0:
	arr = input()
	(n, c0, c1, h) = map(int, arr.split())
	s = input()
	if c0 == c1:
		print(c0 * len(s))
		t -= 1
		continue
	ans = 0
	if c0 > c1:
		if h + c1 < c0:
			for i in s:
				if i == '0':
					ans += h + c1
				else:
					ans += c1
		else:
			for i in s:
				if i == '0':
					ans += c0
				else:
					ans += c1
	elif c1 > c0:
		if h + c0 < c1:
			for i in s:
				if i == '1':
					ans += h + c0
				else:
					ans += c0
		else:
			for i in s:
				if i == '0':
					ans += c0
				else:
					ans += c1
	print(ans)
	t -= 1


t = int(input())
for whatever in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = str(input())
	ans = 0
	for c in s:
		if c == '0':
			ans += min(c0, c1 + h)
		else:
			ans += min(c1, c0 + h)
	print(ans)


t = int(input())
for q in range(t):
	(n, c0, c1, h) = list(map(int, input().split()))
	s = input()
	n1 = 0
	n0 = 0
	for i in s:
		if i == '1':
			n1 += 1
		else:
			n0 += 1
	if c0 - c1 > h:
		print(n * c1 + h * n0)
	elif c1 - c0 > h:
		print(n * c0 + h * n1)
	else:
		print(n1 * c1 + n0 * c0)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	p = input()
	a = p.count('0')
	b = p.count('1')
	print(min((h + c0) * b + c0 * a, c1 * b + (h + c1) * a, c1 * b + c0 * a))


def min_price(s, c0, c1, h):
	best_c0 = c0
	best_c1 = c1
	if c0 > c1:
		if c1 + h < c0:
			best_c0 = c1 + h
	elif c1 > c0:
		if c0 + h < c1:
			best_c1 = c0 + h
	price = s.count('0') * best_c0 + s.count('1') * best_c1
	return price
t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	print(min_price(s, c0, c1, h))


x = input()
for el in range(int(x)):
	(a, b, c, d) = map(int, input().split())
	s = input()
	one = s.count('1')
	zero = s.count('0')
	minimum = min(b, c)
	maximum = max(b, c)
	if minimum + d < maximum:
		if b < c:
			print(zero * b + one * (b + d))
		else:
			print(zero * (c + d) + one * c)
	else:
		print(zero * b + one * c)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	ones = 0
	zeros = 0
	for c in s:
		if c == '0':
			zeros += 1
		else:
			ones += 1
	if c0 == c1:
		print(len(s) * c0)
	elif c0 < c1:
		if c0 + h < c1:
			print((c0 + h) * ones + c0 * zeros)
		else:
			print(c0 * zeros + c1 * ones)
	elif c1 + h < c0:
		print(c1 * ones + (c1 + h) * zeros)
	else:
		print(c0 * zeros + c1 * ones)


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	l0 = s.count('0')
	l1 = s.count('1')
	ans = 10 ** 18
	for j in range(l0 + 1):
		for k in range(l1 + 1):
			ans = min(ans, j * c0 + (l0 - j) * h + k * c1 + (l1 - k) * h + (l1 - k) * c0 + (l0 - j) * c1)
	print(ans)


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	z = s.count('0')
	o = n - z
	if c0 > c1:
		(c0, c1) = (c1, c0)
		(z, o) = (o, z)
	if h > c1:
		print(z * c0 + o * c1)
	else:
		m = c1 * o + c0 * z
		for i in range(0, o + 1):
			k = i * h + c1 * (o - i)
			m = min(m, k + (z + i) * c0)
		print(m)


for _ in range(int(input())):
	(n, c0, c1, h) = [int(i) for i in input().split()]
	s = list(input())
	if h >= abs(c1 - c0):
		print(s.count('0') * c0 + s.count('1') * c1)
	elif max(c0, c1) == c1:
		print(c0 * n + s.count('1') * h)
	else:
		print(s.count('0') * h + c1 * n)


t = int(input())
while t > 0:
	t -= 1
	(n, c0, c1, h) = [int(x) for x in input().split()]
	s = input()
	ans = 0
	for i in range(n):
		if s[i] == '0':
			ans += min(c0, c1 + h)
		else:
			ans += min(c1, c0 + h)
	print(ans)


t = int(input())
for fgugh in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	o = s.count('1')
	z = s.count('0')
	cmax = max(c0, c1)
	maix = max(cmax, h)
	if maix == h:
		print(o * c1 + c0 * z)
	elif cmax == c0:
		if h * z + c1 * z < c0 * z:
			print(o * c1 + h * z + z * c1)
		else:
			print(o * c1 + c0 * z)
	elif h * o + c0 * o < c1 * o:
		print(c0 * z + h * o + o * c0)
	else:
		print(o * c1 + c0 * z)


def min_change(n_cList, s):
	n = n_cList[0]
	c0 = n_cList[1]
	c1 = n_cList[2]
	h = n_cList[3]
	answer = 0
	for i in range(len(s)):
		if s[i] == '0':
			answer += min(c0, c1 + h)
		else:
			answer += min(c1, c0 + h)
	return answer
t = int(input())
ans_arr = []
for i in range(t):
	n_cList = list(map(int, input().split()))
	s = str(input())
	ans = min_change(n_cList, s)
	ans_arr.append(ans)
for j in ans_arr:
	print(j)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	a = input()
	if min(c0, c1) + h < max(c0, c1):
		if c0 > c1:
			print(a.count('0') * h + n * c1)
		else:
			print(a.count('1') * h + n * c0)
	else:
		t = a.count('0')
		print(t * c0 + (n - t) * c1)


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	count_0 = s.count('0')
	count_1 = len(s) - count_0
	if c0 + h < c1:
		print(c0 * count_0 + (c0 + h) * count_1)
	elif c1 + h < c0:
		print(c1 * count_1 + (c1 + h) * count_0)
	else:
		print(c0 * count_0 + c1 * count_1)


from sys import stdin, stdout
mp = lambda : map(int, stdin.readline().split())
li = lambda : list(map(int, stdin.readline().split()))
for _ in range(int(input())):
	(n, c0, c1, h) = mp()
	s = input()
	ct0 = s.count('0')
	ct1 = s.count('1')
	if c0 > c1:
		if h + c1 < c0:
			print(h * ct0 + (ct0 + ct1) * c1)
		else:
			print(c0 * ct0 + c1 * ct1)
	elif h + c0 < c1:
		print(h * ct1 + (ct0 + ct1) * c0)
	else:
		print(c0 * ct0 + c1 * ct1)


tt = int(input())
arrow = []
while tt > 0:
	w = input()
	w = w.split()
	n = int(w[0])
	c0 = int(w[1])
	c1 = int(w[2])
	h = int(w[3])
	a = input()
	n0 = a.count('0')
	n1 = a.count('1')
	s01 = c0 * n0 + c1 * n1
	s0 = h * n1 + len(a) * c0
	s1 = h * n0 + len(a) * c1
	ans = min(s01, s0, s1)
	arrow.append(ans)
	tt -= 1
for i in range(len(arrow)):
	print(arrow[i])


for tc in range(int(input())):
	(n, c0, c1, h) = [int(i) for i in input().strip().split()]
	s = [int(i) for i in input()]
	a = sum(s)
	b = n - a
	if c0 > c1 + h:
		c0 = c1 + h
	elif c1 > c0 + h:
		c1 = c0 + h
	res = b * c0 + a * c1
	print(res)


for i in range(int(input())):
	(n, co, c1, h) = map(int, input().split())
	s = str(input())
	ans = 0
	for i in s:
		if i == '0':
			ans += min(co, h + c1)
		elif i == '1':
			ans += min(c1, h + co)
	print(ans)


t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	sum1 = 0
	if c0 > h + c1:
		c0 = c1 + h
	if c1 > c0 + h:
		c1 = c0 + h
	for j in range(n):
		if s[j] == '0':
			sum1 += c0
		else:
			sum1 += c1
	print(sum1)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	li = list(input())
	ones = li.count('1')
	zeros = li.count('0')
	re = []
	re.append(c0 * n + ones * h)
	re.append(c1 * n + zeros * h)
	re.append(c0 * zeros + c1 * ones)
	print(min(re))


def farr(s):
	all_freq = {}
	for i in s:
		if i in all_freq:
			all_freq[i] += 1
		else:
			all_freq[i] = 1
	return all_freq

def nextInt():
	return int(input())

def intArr():
	arr = input().split(' ')
	return [int(x) for x in arr]
t = nextInt()
ans = []
for tt in range(t):
	a = intArr()
	s = str(input())
	c0 = a[1]
	c1 = a[2]
	h = a[3]
	if c0 == c1:
		ans.append(len(s) * c0)
	elif c0 < c1:
		if h + c0 > c1:
			cost = 0
			for x in s:
				if x == '0':
					cost += c0
				else:
					cost += c1
			ans.append(cost)
		else:
			cost = 0
			for x in s:
				if x == '0':
					cost += c0
				elif x == '1':
					cost += h + c0
			ans.append(cost)
	elif c1 < c0:
		if h + c1 > c0:
			cost = 0
			for x in s:
				if x == '0':
					cost += c0
				else:
					cost += c1
			ans.append(cost)
		else:
			cost = 0
			for x in s:
				if x == '0':
					cost += h + c1
				else:
					cost += c1
			ans.append(cost)
for x in ans:
	print(x)


def countmin(binary, x):
	if binary == '':
		return 0
	L = int(x[0])
	priceof0 = int(x[1])
	priceof1 = int(x[2])
	priceofchange = int(x[3])
	if priceof0 == priceof1:
		return L * priceof1
	else:
		n0 = 0
		n1 = 0
		for i in binary:
			if i == '0':
				n0 += 1
			else:
				n1 += 1
		if priceofchange + min(priceof1, priceof0) > max(priceof1, priceof0):
			return n0 * priceof0 + n1 * priceof1
		else:
			currentprice = n0 * priceof0 + n1 * priceof1
			if min(priceof0, priceof1) == priceof0:
				currentprice -= n1 * (priceof1 - priceof0)
				currentprice += n1 * priceofchange
			else:
				currentprice -= n0 * (-1 * (priceof1 - priceof0))
				currentprice += n0 * priceofchange
	return currentprice
T = int(input())
for i in range(T):
	x = input().split()
	binary = list(input())
	print(countmin(binary, x))


rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input()
yn = lambda x: print('Yes') if x else print('No')
YN = lambda x: print('YES') if x else print('NO')
pl = lambda l: print(' '.join(list(map(str, l))))
for _ in range(rn()):
	(n, a, b, h) = rns()
	s = rs()
	if a < b:
		z = s.count('0')
		o = s.count('1')
		ans = z * a + o * h + o * a
		print(min(ans, z * a + o * b))
	elif a > b:
		z = s.count('0')
		o = s.count('1')
		ans = z * h + o * b + z * b
		print(min(ans, z * a + o * b))
	else:
		print(n * a)


t = int(input())
for _ in range(t):
	(n, c, c1, h) = map(int, input().split())
	a = input()
	zero = 0
	one = 0
	for items in a:
		if items == '0':
			zero += 1
		else:
			one += 1
	z1 = zero * c + one * c1
	z2 = n * c + h * one
	z3 = n * c1 + h * zero
	print(min(z1, z2, z3))


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = list(map(int, input().split()))
	s = input()
	n0 = s.count('0')
	n1 = s.count('1')
	cost = 0
	if c1 > c0:
		if c1 >= c0 + h:
			cost = n * c0 + n1 * h
		else:
			cost = n0 * c0 + n1 * c1
	elif c0 >= c1 + h:
		cost = c1 * n + n0 * h
	else:
		cost = n0 * c0 + n1 * c1
	print(cost)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	nc0 = s.count('0')
	nc1 = n - nc0
	print(min(nc0 * c0 + nc1 * c1, c0 * n + h * nc1, c1 * n + h * nc0))


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	z = input()
	x = z.count('0')
	y = z.count('1')
	if c0 > c1 + h:
		print(n * c1 + x * h)
	elif c1 > c0 + h:
		print(n * c0 + y * h)
	else:
		print(c0 * x + c1 * y)


t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split(' '))
	s = input()
	z = s.count('0')
	one = s.count('1')
	a = c0 * z + c1 * one
	for i in range(1, z + 1):
		t = i * h + c0 * (z - i) + c1 * (one + i)
		a = min(t, a)
	for i in range(1, one + 1):
		t = i * h + c0 * (z + i) + c1 * (one - i)
		a = min(t, a)
	print(a)


from math import *
n = int(input())
while n:
	(x, y, z, d) = [int(i) for i in input().split()]
	ans = 0
	s = str(input())
	for i in s:
		if i == '0':
			ans += min(y, z + d)
		else:
			ans += min(y + d, z)
	print(ans)
	n -= 1


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	a = str(input())
	z = 0
	o = 0
	for x in range(len(a)):
		if a[x] == '1':
			o += 1
		else:
			z += 1
	arr = [c0 * z + (c0 + h) * o, c0 * z + c1 * o, (c1 + h) * z + c1 * o]
	print(min(arr))


from collections import Counter
import sys
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())
n = None
c0 = None
c1 = None
h = None
s = None
t = int(input())
for i in range(t):
	(n, c0, c1, h) = invr()
	s = insr()
	counter = Counter(s)
	f1 = None
	f0 = None
	try:
		f1 = int(counter.get('1'))
	except:
		f1 = 0
	try:
		f0 = int(counter.get('0'))
	except:
		f0 = 0
	cost = 0
	cost1 = 0
	cost2 = 0
	if c0 > c1:
		cost1 = h * f0 + n * c1
		cost2 = f0 * c0 + f1 * c1
		if cost1 < cost2:
			cost = cost1
		else:
			cost = cost2
	elif c0 < c1:
		cost1 = h * f1 + n * c0
		cost2 = f0 * c0 + f1 * c1
		if cost1 < cost2:
			cost = cost1
		else:
			cost = cost2
	elif c0 == c1:
		cost = c0 * n
	print(cost)


t = int(input())
while t:
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	(n1, n0) = (0, 0)
	for i in range(n):
		if s[i] == '1':
			n1 += 1
		else:
			n0 += 1
	m = min(c0 * n + h * n1, c1 * n + h * n0, c0 * n0 + c1 * n1)
	print(m)
	t -= 1


import sys
from math import ceil, factorial, gcd
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify
MOD = 10 ** 9 + 7
INF = float('inf')
rl = lambda : list(map(int, sys.stdin.readline().split()))
for _ in range(int(input())):
	(n, c0, c1, h) = rl()
	s = sys.stdin.readline()
	if h >= abs(c0 - c1):
		print(s.count('0') * c0 + s.count('1') * c1)
	elif c0 > c1:
		print(s.count('0') * h + n * c1)
	else:
		print(s.count('1') * h + n * c0)


n = int(input())
for i in range(n):
	(n, c0, c1, h) = map(int, input().split())
	string = str(input())
	cost = 0
	for char in string:
		if char == '0':
			cost += min(c0, c1 + h)
		else:
			cost += min(c1, c0 + h)
	print(cost)


import sys

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

def iinput():
	return int(input())

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

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	(n, c0, c1, h) = rinput()
	s = input()
	z = s.count('0')
	o = s.count('1')
	print(min(z * c0 + o * c1, n * c1 + h * z, n * c0 + h * o))


for _ in [0] * int(input()):
	(n, zero, one, h) = map(int, input().split())
	r = [*map(int, list(input()))]
	one_in_r = r.count(1)
	zero_in_r = n - one_in_r
	if zero > one + h:
		print(n * one + zero_in_r * h)
	elif one > zero + h:
		print(n * zero + one_in_r * h)
	else:
		print(zero * zero_in_r + one * one_in_r)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	a = s.count('0')
	b = s.count('1')
	if c0 <= c1:
		if c1 > c0 + h:
			print(n * c0 + h * b)
		else:
			print(c0 * a + b * c1)
	elif c0 > c1 + h:
		print(n * c1 + h * a)
	else:
		print(c0 * a + b * c1)


m = int(input())
l = []
for i in range(m):
	(n, c1, c2, h) = map(int, input().split())
	s = input()
	a = len(s)
	a0 = s.count('0')
	a1 = s.count('1')
	if c1 == c2:
		l.append(a * c1)
	elif c1 < c2:
		l.append(min(a1 * h + a * c1, a0 * c1 + a1 * c2))
	else:
		l.append(min(a0 * h + a * c2, a1 * c2 + a0 * c1))
for i in l:
	print(i)


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	one = 0
	zero = 0
	if c0 + h < c1:
		c1 = c0 + h
	if c1 + h < c0:
		c0 = c1 + h
	for i in range(n):
		if s[i] == '0':
			zero += c0
		else:
			one += c1
	print(zero + one)


I = input
for _ in [0] * int(I()):
	(n, c, d, h) = map(int, I().split())
	k = I().count('0')
	print(min((a * (h - c + d) + b * (h + c - d) + k * (c - d) + n * d for a in (0, k) for b in (0, n - k))))


def dfs(idx):
	global n, c0, c1, h
	if idx == n - 1:
		if s[idx] == '0':
			dp[idx] = c0 if c0 < c1 + h else c1 + h
			return dp[idx]
		else:
			dp[idx] = c1 if c1 < c0 + h else c0 + h
			return dp[idx]
	elif dp[idx] < float('inf'):
		return dp[idx]
	else:
		if s[idx] == '0':
			cost = dfs(idx + 1)
			dp[idx] = c0 + cost if c0 + cost < c1 + cost + h else c1 + cost + h
		else:
			cost = dfs(idx + 1)
			dp[idx] = c1 + cost if c1 + cost < c0 + cost + h else c0 + cost + h
		return dp[idx]
t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = list(input())
	dp = [float('inf')] * n
	print(dfs(0))


t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	s = input()
	c = min(c, d + b)
	b = min(b, d + c)
	print(s.count('0') * b + s.count('1') * c)


for i in range(int(input())):
	(n, c_0, c_1, h) = map(int, input().split())
	l = input()
	p = 0
	m = 0
	if c_0 > c_1:
		c = l.count('0')
		m = c_0 * c + c_1 * (len(l) - c)
		for i in range(c):
			p = m - c_0 + (c_1 + h)
			if p < m:
				m = p
			else:
				break
	elif c_1 >= c_0:
		c = l.count('1')
		m = c_1 * c + c_0 * (len(l) - c)
		for i in range(c):
			p = m - c_1 + (c_0 + h)
			if p < m:
				m = p
			else:
				break
	print(m)
	print()


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	stroka = input()
	if abs(c0 - c1) <= h:
		print(c0 * stroka.count('0') + c1 * stroka.count('1'))
	elif c1 - c0 > h:
		print(c0 * len(stroka) + h * stroka.count('1'))
	else:
		print(c1 * len(stroka) + h * stroka.count('0'))


import sys
from collections import Counter
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	C = Counter(input().strip())
	cost = min(c0 * C['0'] + c1 * C['1'], c0 * n + C['1'] * h, c1 * n + C['0'] * h)
	print(cost)


for tc in range(int(input())):
	(n, c0, c1, h) = [int(i) for i in input().strip().split(' ')]
	s = [int(i) for i in input()]
	s1 = sum(s)
	s0 = n - s1
	if c0 > c1 + h:
		c0 = c1 + h
	elif c1 > c0 + h:
		c1 = c0 + h
	res = s0 * c0 + s1 * c1
	print(res)


for _ in range(int(input())):
	(n, c0, c1, h) = input().split()
	(n, c0, c1, h) = (int(n), int(c0), int(c1), int(h))
	s = input()
	n0 = 0
	n1 = s.count('1')
	n0 = n - n1
	ans = 0
	if h >= c0 and h >= c1 or c0 == c1:
		ans = n0 * c0 + n1 * c1
	elif c0 > c1:
		ans = min(n0 * h + n * c1, n0 * c0 + n1 * c1)
	elif c1 > c0:
		ans = min(n1 * h + n * c0, c0 * n0 + c1 * n1)
	print(ans)


t = int(input())
for _ in range(t):
	(n, c_0, c_1, h) = map(int, input().split())
	s = input()
	count_0 = 0
	count_1 = 0
	for x in s:
		if x == '0':
			count_0 += 1
		else:
			count_1 += 1
	costs = 0
	if c_0 + h < c_1:
		count_0 += count_1
		costs += count_1 * h
		count_1 = 0
	if c_1 + h < c_0:
		count_1 += count_0
		costs += count_0 * h
		count_0 = 0
	costs += count_0 * c_0 + count_1 * c_1
	print(costs)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

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

def solve():
	(n, c0, c1, h) = rl()
	s = input()
	zeros = s.count('0')
	ones = s.count('1')
	cost = zeros * min(c0, h + c1) + ones * min(c1, h + c0)
	print(cost)
mode = 'T'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = str(input())
	x0 = 0
	x1 = 0
	for i in range(n):
		if s[i] == '0':
			x0 += 1
		else:
			x1 += 1
	ans = 10 ** 18
	for i in range(x0 + 1):
		for j in range(x1 + 1):
			temp = i * h + j * h + (x0 - i + j) * c0 + (x1 - j + i) * c1
			ans = min(temp, ans)
	print(ans)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	sum = 0
	for item in s:
		if item == '0':
			sum += min(c0, h + c1)
		else:
			sum += min(c1, c0 + h)
	print(sum)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
import bisect
from types import GeneratorType
BUFSIZE = 8192

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

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

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			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')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7
mod = 10 ** 9 + 7
t = int(input())
p = 10 ** 9 + 7

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def z_array(s1):
	n = len(s1)
	z = [0] * n
	(l, r, k) = (0, 0, 0)
	for i in range(1, n):
		if i > r:
			(l, r) = (i, i)
			while r < n and s1[r - l] == s1[r]:
				r += 1
			z[i] = r - l
			r -= 1
		else:
			k = i - l
			if z[k] < r - i + 1:
				z[i] = z[k]
			else:
				l = i
				while r < n and s1[r - l] == s1[r]:
					r += 1
				z[i] = r - l
				r -= 1
	return z

def solve():
	(x, y) = (0, 0)
	for i in s:
		if i == '0':
			x += 1
		else:
			y += 1
	ans = x * c0 + y * c1
	if c0 > c1 + h:
		return x * (c1 + h) + y * c1
	if c1 > c0 + h:
		return x * c0 + y * (c0 + h)
	return ans
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	print(solve())


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	z = s.count('0')
	x = s.count('1')
	p = z * c0 + x * c1
	a = z * h
	b = x * h
	u = n * c1 + a
	i = n * c0 + b
	print(min(p, u, i))


import math
from collections import defaultdict as dfc

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for p in range(2, n + 1):
		if prime[p]:
			l += [p]
	return l

def i1():
	return int(input())

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

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

def i4():
	return input()
m = 2 ** 32
for i in range(i1()):
	(n, c0, c1, h) = i2()
	s = i4()
	a = s.count('0')
	b = s.count('1')
	ap = a * c0
	bp = b * c1
	print(min(ap + bp, a * h + (a + b) * c1, b * h + (a + b) * c0))


def solve(n, c0, c1, h):
	s = input()
	(t0, t1) = (0, 0)
	for i in s:
		if i == '0':
			t0 += 1
		else:
			t1 += 1
	if c0 <= c1:
		return min(c0 * n + t1 * h, c0 * t0 + c1 * t1)
	else:
		return min(c1 * n + t0 * h, c0 * t0 + c1 * t1)
for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	print(solve(n, c0, c1, h))


import sys

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

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

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, c0, c1, h) = get_ints()
	s = input()
	zeros = s.count('0')
	ones = s.count('1')
	ans = 0
	if h + c1 < c0:
		ans += zeros * (h + c1)
	if h + c1 >= c0:
		ans += zeros * c0
	if h + c0 < c1:
		ans += ones * (h + c0)
	if h + c0 >= c1:
		ans += ones * c1
	print(ans)


def f():
	(n, z, u, h) = list(map(int, input().split()))
	s = input()
	nz = sum([1 if c == '0' else 0 for c in s])
	nu = sum([1 if c == '1' else 0 for c in s])
	if z > h + u:
		print(nz * (h + u) + nu * u)
	elif u > z + h:
		print(nz * z + nu * (h + z))
	else:
		print(nz * z + nu * u)
t = int(input())
for i in range(t):
	f()


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	m0 = s.count('0')
	m1 = s.count('1')
	if c1 > c0 + h:
		print(c0 * m0 + (c0 + h) * m1)
	elif c0 > c1 + h:
		print(c1 * m1 + (c1 + h) * m0)
	else:
		print(c1 * m1 + c0 * m0)


t = int(input())
while t:
	t -= 1
	(n, c0, c1, h) = [int(x) for x in input().split()]
	s = input()
	one_count = s.count('1')
	zero_count = s.count('0')
	res = 0
	if c1 > c0:
		res += c0 * zero_count
		if h + c0 > c1:
			res += c1 * one_count
		else:
			res += (h + c0) * one_count
	else:
		res += c1 * one_count
		if h + c1 > c0:
			res += c0 * zero_count
		else:
			res += (h + c1) * zero_count
	print(res)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	zero = s.count('0')
	one = s.count('1')
	cost = zero * c0 + one * c1
	ans = cost
	for i in range(zero):
		cost1 = (zero - (i + 1)) * c0 + (one + i + 1) * c1 + h * (i + 1)
		ans = min(cost1, ans)
	for i in range(one):
		cost1 = (zero + (i + 1)) * c0 + (one - (i + 1)) * c1 + h * (i + 1)
		ans = min(ans, cost1)
	print(ans)


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import threading
import sys
import time

def get_int():
	return int(stdin.readline().strip())

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

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

def solve():
	(n, c0, c1, h) = get_tuple()
	st = input()
	(z, o) = (st.count('0'), st.count('1'))
	if c0 == c1:
		print(n * c0)
	elif c0 < c1:
		if c0 + h <= c1:
			print(z * c0 + o * (c0 + h))
		else:
			print(z * c0 + o * c1)
	elif c1 + h <= c0:
		print(o * c1 + z * (c1 + h))
	else:
		print(z * c0 + o * c1)
testcases = True
if testcases:
	t = get_int()
	for _ in range(t):
		solve()
else:
	solve()


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = str(input())
	if c1 >= c0 + h:
		ans = s.count('0') * c0 + s.count('1') * (c0 + h)
	elif c0 >= c1 + h:
		ans = s.count('0') * (c1 + h) + s.count('1') * c1
	else:
		ans = s.count('0') * c0 + s.count('1') * c1
	print(ans)


import sys
input = lambda : sys.stdin.readline().rstrip()

def driver():
	T = int(input())
	for _ in range(T):
		(a, b, c, d) = [int(g) for g in input().split()]
		sen = input()
		total = 0
		for char in sen:
			if char == '0':
				total += min(b, c + d)
			else:
				total += min(c, b + d)
		print(total)
driver()


t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	count0 = 0
	count1 = 0
	for j in range(n):
		if s[j] == '0':
			count0 += 1
		else:
			count1 += 1
	a = n * c1 + count0 * h
	b = n * c0 + count1 * h
	c = count1 * c1 + count0 * c0
	print(min(a, b, c))


def solution(n, c0, c1, h, s):
	s = [int(e) for e in str(s)]
	if c1 > c0 and h < c1 - c0:
		return sum((c0 + h if e else c0 for e in s))
	elif c0 > c1 and h < c0 - c1:
		return sum((c1 if e else c1 + h for e in s))
	else:
		return sum((c1 if e else c0 for e in s))
t = int(input())
for _ in range(t):
	(n, c0, c1, h) = [int(e) for e in input().split(' ')]
	s = input()
	print(solution(n, c0, c1, h, s))


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = str(input())
	if c0 == c1:
		print(c0 * len(s))
	else:
		a = c0 * len(s) + h * s.count('1')
		b = c1 * len(s) + h * s.count('0')
		c = c0 * s.count('0') + c1 * s.count('1')
		print(min(a, b, c))


from collections import Counter
import copy

def solve():
	(n, c0, c1, h) = list(map(int, input().split()))
	string = input()
	count = Counter(string)
	if c0 == c1:
		return len(string) * c0
	if c0 > c1:
		if c0 * count['0'] + c1 * count['1'] <= h * count['0'] + c1 * len(string):
			return c0 * count['0'] + c1 * count['1']
		return h * count['0'] + c1 * len(string)
	else:
		if c1 * count['1'] + c0 * count['0'] <= h * count['1'] + c0 * len(string):
			return c0 * count['0'] + c1 * count['1']
		return h * count['1'] + c0 * len(string)
for i in range(int(input())):
	print(solve())


from collections import Counter

def fun(n, c0, c1, h, st):
	dct = Counter(st)
	count1 = dct.get('1') if dct.get('1') != None else 0
	count0 = dct.get('0') if dct.get('0') != None else 0
	if c0 > c1:
		print(min((count1 + count0) * c1 + count0 * h, count1 * c1 + count0 * c0))
	else:
		print(min((count1 + count0) * c0 + count1 * h, count1 * c1 + count0 * c0))
T = int(input())
for i in range(T):
	(n, c0, c1, h) = list(map(int, input().split()))
	st = input()
	fun(n, c0, c1, h, st)


from sys import *
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	if c0 == c1:
		print(n * c0)
		continue
	(a, b) = (0, 0)
	for i in s.strip():
		if i == '0':
			a += 1
		else:
			b += 1
	if h >= max(c0, c1):
		print(a * c0 + b * c1)
	elif c0 > c1 + h:
		print(a * h + n * c1)
	elif c1 > c0 + h:
		print(b * h + n * c0)
	else:
		print(a * c0 + b * c1)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

def si():
	return input().rstrip()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 998244353
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def solve():
	for _ in range(ii()):
		(n, a, b, h) = mi()
		s = list(si())
		one = s.count('1')
		zero = s.count('0')
		if a + h < b:
			print(zero * a + one * (a + h))
		elif a > b + h:
			print(one * b + zero * (b + h))
		else:
			print(a * zero + b * one)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


I = input
for _ in range(int(I())):
	(n, a, b, c) = map(int, I().split())
	s = I()
	x = s.count('0')
	if b < a:
		(a, b) = (b, a)
		x = n - x
	print(x * a + (n - x) * min(c + a, b))


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	cost = 0
	for i in s:
		if i == '0':
			if c0 <= c1 + h:
				cost += c0
			else:
				cost += c1 + h
		elif c1 <= c0 + h:
			cost += c1
		else:
			cost += c0 + h
	print(cost)


def minCoin(n, c0, c1, h, s):
	if c0 == c1:
		return c0 * n
	elif c0 < c1:
		if c0 + h >= c1:
			return c0 * s.count('0') + c1 * s.count('1')
		else:
			return c0 * s.count('0') + (c0 + h) * s.count('1')
	elif c1 + h >= c0:
		return c1 * s.count('1') + c0 * s.count('0')
	else:
		return c1 * s.count('1') + (c1 + h) * s.count('0')
t = int(input())
for i in range(t):
	(n, c0, c1, h) = [int(x) for x in input().split()]
	s = input()
	print(minCoin(n, c0, c1, h, s))


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = (int(i) for i in input().split())
	s = input()
	(_, ones) = ((zeros := s.count('0')), n - zeros)
	res = min(zeros * c0 + ones * c1, n * c0 + h * ones, n * c1 + h * zeros)
	print(res)


for _ in range(int(input())):
	(n, c0, c1, h) = list(map(int, input().split(' ')))
	s = input()
	s0 = s.count('0')
	s1 = s.count('1')
	if c0 > c1:
		(c0, c1) = (c1, c0)
		(s0, s1) = (s1, s0)
	total = 0
	if c0 + h < c1:
		total = (c0 + h) * s1 + s0 * c0
	else:
		total = c1 * s1 + s0 * c0
	print(total)


for _ in range(int(input())):
	(n, a, b, h) = map(int, input().split())
	s = input()
	cnt = s.count('0')
	d = a - b
	if d > h:
		print(n * b + cnt * h)
	elif -d > h:
		print(n * a + (n - cnt) * h)
	else:
		print(cnt * a + (n - cnt) * b)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	sm1 = s.count('1') * c1 + s.count('0') * c0
	if c0 <= c1:
		sm2 = s.count('1') * h + n * c0
	else:
		sm2 = s.count('0') * h + n * c1
	print(min(sm1, sm2))


for _ in range(int(input())):
	arr = [int(_) for _ in input().split()]
	val = input()
	v1 = arr[0] * arr[1] + val.count('1') * arr[3]
	v2 = arr[0] * arr[2] + val.count('0') * arr[3]
	v3 = arr[1] * val.count('0') + arr[2] * val.count('1')
	print(min(v1, v2, v3))


t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	a = s.count('1')
	b = s.count('0')
	res = a * c1 + b * c0
	res1 = a * h + n * c0
	res2 = b * h + n * c1
	print(min(res, res1, res2))


for ti in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	n1 = s.count('1')
	n0 = s.count('0')
	print(n1 * min(c1, h + c0) + n0 * min(c0, h + c1))


for t in range(int(input())):
	x = list(map(int, input().split()))
	s = input()
	n0 = 0
	n1 = 0
	for i in s:
		if i == '0':
			n0 = n0 + 1
		else:
			n1 = n1 + 1
	tot = n0 * x[1] + n1 * x[2]
	if x[3] + x[1] < x[2]:
		tot = n0 * x[1] + n1 * (x[3] + x[1])
	if x[3] + x[2] < x[1]:
		tot = n0 * (x[3] + x[2]) + n1 * x[2]
	print(tot)


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	cost = 0
	m0 = min(c0, c1 + h)
	m1 = min(c0 + h, c1)
	for i in s:
		if i == '0':
			cost += m0
		else:
			cost += m1
	print(cost)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	ones = s.count('1')
	zeroes = n - ones
	if c0 + h == c1 or c1 + h == c0 or (c1 + h > c0 and c0 + h > c1):
		print(zeroes * c0 + ones * c1)
	elif c0 + h < c1:
		print(n * c0 + ones * h)
	elif c1 + h < c0:
		print(n * c1 + zeroes * h)


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	q = s.count('1')
	print(min(q * c1 + (n - q) * c0, q * (h + c0) + (n - q) * c0, q * c1 + (n - q) * (h + c1)))


import math

def prime(a):
	for i in range(2, int(a ** 0.5) + 1):
		if a % i == 0:
			return 0
	return 1
t = int(input())
for test in range(t):
	tt = 0
	pp = 0
	cc = ''
	ss = ''
	dd = 1
	cnttt = 0
	damn = 1e+18
	ammo = 'FULL'
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	o = 0
	z = 0
	for i in range(n):
		if s[i] == '1':
			o += 1
		else:
			z += 1
	ans = c0 * z + c1 * o
	i = z
	while i >= 0:
		aa = c0 * i + c1 * (o + z - i) + h * (z - i)
		ans = min(ans, aa)
		i -= 1
	i = o
	while i >= 0:
		aa = c0 * (z + o - i) + c1 * i + h * (o - i)
		ans = min(ans, aa)
		i -= 1
	print(ans)


for z in range(int(input())):
	(n, c, d, h) = map(int, input().split())
	a = str(input())
	a0 = a.count('0')
	a1 = a.count('1')
	if c <= d:
		if d >= c + h:
			print(a0 * c + a1 * (c + h))
		else:
			print(a0 * c + a1 * d)
	elif c >= d + h:
		print(a1 * d + a0 * (d + h))
	else:
		print(a1 * d + a0 * c)


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	a = s.count('1') * c1
	b = s.count('0') * c0
	c = a + b
	if c1 > c0:
		ans1 = s.count('1') * h
		ab = ans1 + n * c0
		print(min(c, ab))
	elif c1 < c0:
		ans1 = s.count('0') * h
		ab = ans1 + n * c1
		print(min(c, ab))
	elif c1 == c0:
		print(c)


for i in range(int(input())):
	(n, c0, c1, h) = [int(i) for i in input().split()]
	s = input()
	ans = 0
	a0 = s.count('0')
	a1 = s.count('1')
	if c0 < c1:
		ans = a0 * c0
		if h + c0 < c1:
			ans += (h + c0) * a1
		else:
			ans += a1 * c1
	else:
		ans = a1 * c1
		if h + c1 < c0:
			ans += (h + c1) * a0
		else:
			ans += a0 * c0
	print(ans)


for i in range(int(input())):
	(n, a, b, h) = map(int, input().split())
	s = input()
	l = list(s)
	c0 = l.count('0')
	c1 = l.count('1')
	if a >= b and b + h < a:
		print(h * c0 + len(l) * b)
	elif b > a and a + h < b:
		print(h * c1 + len(l) * a)
	else:
		print(a * c0 + b * c1)


t = int(input())
for i in range(t):
	(n, c0, c1, h) = input().split(' ')
	(n, c0, c1, h) = (int(n), int(c0), int(c1), int(h))
	digits = input()
	digit0 = digits.count('0')
	digit1 = n - digit0
	if h >= c0 and h >= c1:
		print(digit0 * c0 + digit1 * c1)
	elif c0 <= h and c1 > h:
		if c0 + h < c1:
			print(digit0 * c0 + digit1 * (c0 + h))
		else:
			print(digit0 * c0 + digit1 * c1)
	elif c0 > h and c1 <= h:
		if c1 + h < c0:
			print(digit0 * (c1 + h) + digit1 * c1)
		else:
			print(digit0 * c0 + digit1 * c1)
	elif c1 < c0 and c1 + h < c0:
		print(digit0 * (h + c1) + digit1 * c1)
	elif c0 < c1 and c0 + h < c1:
		print(digit0 * c0 + digit1 * (h + c0))
	else:
		print(digit0 * c0 + digit1 * c1)


n = int(input())
for i in range(n):
	inQ = input()
	Q = inQ.split()
	n = int(Q[0])
	c0 = int(Q[1])
	c1 = int(Q[2])
	h = int(Q[3])
	char = input()
	ans = 0
	for i in range(len(char)):
		if char[i] == '0':
			ans += min(c0, c1 + h)
		else:
			ans += min(c1, c0 + h)
	print(ans)


T = int(input())
for t in range(T):
	(x, c0, c1, h) = map(int, input().split())
	S = input()
	if c0 > c1:
		if h + c1 < c0:
			c0 = h + c1
	elif c1 > c0:
		if h + c0 < c1:
			c1 = h + c0
	P = 0
	for s in S:
		if s == '0':
			P += c0
		elif s == '1':
			P += c1
	print(P)


for _ in range(int(input())):
	(n, c0, c1, h) = list(map(int, input().split()))
	st = list(input())
	count_0 = 0
	for i in st:
		if i == '0':
			count_0 += 1
	count_1 = n - count_0
	if c0 + h < c1:
		print(n * c0 + h * count_1)
	elif c1 + h < c0:
		print(n * c1 + h * count_0)
	else:
		print(count_0 * c0 + count_1 * c1)


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	zero = s.count('0')
	one = s.count('1')
	res0 = n * c0 + one * h
	res1 = n * c1 + zero * h
	res2 = zero * c0 + one * c1
	print(min(res0, res1, res2))


cases = int(input())
o = []
result = []
for i in range(cases):
	(n, co, c1, h) = map(int, input().split())
	o = map(int, list(input()))
	ones = sum(o)
	cost = co * n + (c1 - co) * ones
	if c1 > co:
		val = co * n + h * ones
		result.append(min(val, cost))
	elif c1 < co:
		val = c1 * n + h * (n - ones)
		result.append(min(val, cost))
	else:
		result.append(co * n)
for i in result:
	print(i)


t = int(input())
while t > 0:
	(n, c0, c1, h) = map(int, input().split(' '))
	binary_string = input()
	total = 0
	for c in binary_string:
		if c == '0':
			total += min(c0, h + c1)
		else:
			total += min(c1, h + c0)
	print(total)
	t -= 1


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	arr = list(input())
	if h + c1 < c0:
		print((h + c1) * arr.count('0') + c1 * arr.count('1'))
	elif h + c0 < c1:
		print((h + c0) * arr.count('1') + c0 * arr.count('0'))
	else:
		print(c0 * arr.count('0') + c1 * arr.count('1'))


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	a = s.count('1')
	b = s.count('0')
	if c0 + h < c1:
		ch1 = h * a
		print(ch1 + n * c0)
	elif c1 + h < c0:
		ch0 = h * b
		print(ch0 + n * c1)
	else:
		print(c0 * b + c1 * a)


for _ in range(int(input())):
	(n, a, b, h) = map(int, input().split(' '))
	arr = input()
	zero = arr.count('0')
	one = arr.count('1')
	if zero == 0:
		print(min(b * one, n * h + n * a))
	elif one == 0:
		print(min(a * zero, n * h + n * b))
	else:
		print(min(a * zero + b * one, one * h + n * a, zero * h + n * b))


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = str(input())
	one = s.count('1')
	zero = n - one
	if c0 + h < c1:
		print(zero * c0 + one * (c0 + h))
	elif c1 + h < c0:
		print(one * c1 + (c1 + h) * zero)
	else:
		print(one * c1 + zero * c0)


t = int(input())
for i in range(t):
	(n, c0, c1, h) = list(map(int, input().split()))
	s = input()
	a0 = 0
	a1 = 0
	for j in range(n):
		if s[j] == '0':
			a0 += 1
		else:
			a1 += 1
	print(min(c0 * a0 + c1 * a1, h * a0 + n * c1, h * a1 + n * c0))


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	if c0 < c1:
		if h + c0 >= c1:
			flag = False
		else:
			c1 = h + c0
	elif c0 > c1:
		if h + c1 >= c0:
			flag = False
		else:
			c0 = h + c1
	else:
		pass
	ans = 0
	for i in s:
		if i == '0':
			ans = ans + c0
		else:
			ans = ans + c1
	print(ans)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
import string
ORDA = 97

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

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

def li():
	return [int(i) for i in input().split()]

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

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for _ in range(ii()):
	(n, c0, c1, h) = mi()
	s = input()
	ans = 0
	for c in s:
		ans += min(h + c0, c1) if c == '1' else min(h + c1, c0)
	print(ans)


for x in range(int(input())):
	(n, a, b, h) = map(int, input().split())
	s = input()
	money = 0
	for y in s:
		if y == '0':
			money += min(a, h + b)
		if y == '1':
			money += min(b, a + h)
	print(money)


for _ in range(int(input())):
	(n, c0, c1, h) = [int(w) for w in input().split()]
	x = input()
	a = 0
	for i in x:
		if i == '0':
			a += min(c0, c1 + h)
		else:
			a += min(c1, c0 + h)
	print(a)


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split(' '))
	st = list(input())
	y = st.count('0')
	z = st.count('1')
	a = c0 * y + c1 * z
	if y <= z:
		x = h * y
		ans1 = c1 * n + x
		x2 = h * z
		ans2 = c0 * n + x2
		finans = min(ans1, ans2)
		print(min(a, finans))
	elif z <= y:
		x = h * z
		ans1 = c0 * n + x
		x2 = h * y
		ans2 = c1 * n + x2
		finans = min(ans1, ans2)
		print(min(a, finans))


def buy_string(h, c0, c1, s):
	zeros = sum((1 for char in s if char == '0'))
	val0 = c0 * zeros + c1 * (len(s) - zeros)
	val1 = zeros * h + c1 * len(s)
	val2 = (len(s) - zeros) * h + c0 * len(s)
	return min(val0, val1, val2)
for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	print(buy_string(h, c0, c1, s))


import os
import sys
from io import BytesIO, IOBase

def main():
	for t in range(int(input())):
		(n, c0, c1, h) = map(int, input().split())
		s = input()
		cou0 = s.count('0')
		cou1 = s.count('1')
		print(cou0 * min(c0, c1 + h) + cou1 * min(c1, c0 + h))
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()


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	a = input()
	zero = a.count('0')
	one = a.count('1')
	print(min(zero * h + zero * c1 + one * c1, zero * c0 + one * c1, zero * c0 + one * h + one * c0))


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	num_0 = s.count('0')
	num_1 = n - num_0
	print(min(num_0 * c0 + num_1 * c1, c0 * n + h * num_1, c1 * n + h * num_0))


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = [int(x) for x in input().split()]
	s = input()
	a = s.count('1') * h + n * c0
	b = s.count('0') * h + n * c1
	c = s.count('1') * c1 + s.count('0') * c0
	print(min(a, b, c))


t = int(input())
for test in range(t):
	(n, c0, c1, h) = [int(e) for e in input().split()]
	s = input()
	nz = 0
	no = 0
	for i in s:
		if i == '0':
			nz += 1
		else:
			no += 1
	print(min(c0 * nz + c1 * no, no * h + c0 * n, nz * h + c1 * n))


t = int(input())
while t != 0:
	t -= 1
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	p = c0 * s.count('0') + c1 * s.count('1')
	q = c0 * n + h * s.count('1')
	r = c1 * n + h * s.count('0')
	print(min(p, q, r))


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	d1 = s.count('0')
	d2 = s.count('1')
	m1 = n * c0 + h * d2
	m2 = c0 * d1 + c1 * d2
	m3 = n * c1 + h * d1
	d3 = min(m1, m2, m3)
	print(d3)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	diff = abs(c0 - c1)
	s = list(input())
	cost = 0
	n0 = 0
	n1 = 0
	for i in range(n):
		if s[i] == '0':
			cost = cost + c0
			n0 = n0 + 1
		else:
			cost = cost + c1
			n1 = n1 + 1
	if h >= diff:
		print(cost)
	elif c0 < c1 and diff == c1 - c0:
		print(c0 * n + n1 * h)
	elif c1 < c0 and diff == c0 - c1:
		print(c1 * n + n0 * h)
	else:
		print(cost)


k = []
for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input('')
	if c0 + h < c1:
		k.append(n * c0 + h * s.count('1'))
	elif c1 + h < c0:
		k.append(n * c1 + h * s.count('0'))
	else:
		k.append(c0 * s.count('0') + c1 * s.count('1'))
for i in k:
	print(i)


t = int(input())
for i in range(t):
	k = input().split()
	n = int(k[0])
	a0 = int(k[1])
	a1 = int(k[2])
	h = int(k[3])
	s = input()
	c0 = s.count('0')
	c1 = s.count('1')
	print(c0 * min(a0, a1 + h) + c1 * min(a0 + h, a1))


t = int(input())
for i in range(t):
	x = input()
	n = int(x.split()[0])
	c0 = int(x.split()[1])
	c1 = int(x.split()[2])
	h = int(x.split()[3])
	s = input()
	n0 = 0
	for j in range(n):
		if s[j] == '0':
			n0 += 1
	n1 = n - n0
	if c0 == c1:
		print(c0 * n)
	elif c0 > c1:
		print(n1 * c1 + n0 * min(h + c1, c0))
	else:
		print(n0 * c0 + n1 * min(h + c0, c1))


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	(n, c0, c1, h) = inm()
	s = ins()
	count0 = s.count('0')
	count1 = s.count('1')
	print(min(count0 * c0 + count1 * c1, count0 * h + (count0 + count1) * c1, count1 * h + (count0 + count1) * c0))


t = int(input())
for x in range(t):
	(n, c0, c1, h) = map(int, input().split())
	cadena = str(input())
	if c0 == c1:
		print(n * c0)
	else:
		conta0 = 0
		conta1 = 0
		for element in cadena:
			if element == '0':
				conta0 = conta0 + 1
			else:
				conta1 = conta1 + 1
		pago0 = conta0 * c0
		pago1 = conta1 * c1
		if c0 < c1:
			pagotemp0 = conta1 * c0 + h * conta1
			if pagotemp0 < pago1:
				print(pago0 + pagotemp0)
			else:
				print(pago0 + pago1)
		else:
			pagotemp1 = conta0 * c1 + h * conta0
			if pagotemp1 < pago0:
				print(pago1 + pagotemp1)
			else:
				print(pago0 + pago1)


import sys
import math
from collections import defaultdict, deque
input = sys.stdin.readline

def inar():
	return [int(el) for el in input().split()]

def main():
	t = int(input())
	for _ in range(t):
		(n, c0, c1, h) = inar()
		st = input().strip()
		z = 0
		o = 0
		for i in range(n):
			if st[i] == '0':
				z += 1
			else:
				o += 1
		ans = 10 ** 18
		ans = z * h + n * c1
		ans = min(ans, o * h + n * c0)
		ans = min(ans, z * c0 + o * c1)
		print(ans)
main()


t = int(input())
while t > 0:
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	if c0 == c1:
		print(len(s) * c0)
	elif c0 > c1 and c0 > h + c1:
		cou = s.count('0')
		print(h * cou + len(s) * c1)
	elif c1 > c0 and c1 > h + c0:
		cou = s.count('1')
		print(h * cou + len(s) * c0)
	else:
		cou0 = s.count('0')
		cou1 = s.count('1')
		print(cou0 * c0 + cou1 * c1)
	t -= 1


t = int(input())
while t > 0:
	t -= 1
	(n, a, b, h) = (int(i) for i in input().strip().split(' '))
	x = 0
	y = 0
	s = input()
	l = len(s)
	for i in s:
		if i == '0':
			x += 1
		if i == '1':
			y += 1
	if h + a < b:
		print(a * l + h * y)
	elif h + b < a:
		print(b * l + h * x)
	else:
		print(a * x + b * y)


import sys
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())
N = inp()

def test_case(lnp_list, lnp_string):
	n = lnp_list[0]
	co = lnp_list[1]
	ci = lnp_list[2]
	h = lnp_list[3]
	s = lnp_string
	count_o = s.count('0')
	count_i = s.count('1')
	sell_value = count_o * co + count_i * ci
	if co > ci:
		change_profit = co - ci - h
		if change_profit > 0:
			sell_value = n * ci + h * count_o
	else:
		change_profit = ci - co - h
		if change_profit > 0:
			sell_value = n * co + h * count_i
	print(sell_value)
input_arr = []
for _ in range(N):
	lnp_list = inlt()
	lnp_string = input()
	input_arr.append((lnp_list, lnp_string))
for (lnp_list, lnp_string) in input_arr:
	test_case(lnp_list, lnp_string)


for i in range(int(input())):
	(n, a, b, h) = map(int, input().split())
	s = input()
	print(s.count('0') * min(h + b, a) + s.count('1') * min(h + a, b))


t = int(input())
while t > 0:
	t -= 1
	(n, c1, c2, h) = map(int, input().split())
	s = input()
	a = s.count('0')
	b = s.count('1')
	c = a * c1 + b * c2
	d = a * h + n * c2
	e = b * h + n * c1
	print(min(c, d, e))


import io, os
from math import *
for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	cost = 0
	for c in s:
		if c == '0':
			cost += min(c1 + h, c0)
		else:
			cost += min(c0 + h, c1)
	print(cost)


t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	sr = input()
	arr = list(sr)
	summ1 = 0
	summ2 = 0
	if c0 > c1:
		n1 = arr.count('0')
		summ1 = n1 * h + n * c1
	elif c0 == c1:
		summ1 = n * c1
	else:
		n2 = arr.count('1')
		summ1 = n2 * h + n * c0
	n3 = arr.count('0')
	n4 = arr.count('1')
	summ2 = n3 * c0 + n4 * c1
	if summ1 > summ2:
		print(summ2)
	else:
		print(summ1)


from collections import Counter
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input().strip()
	c = Counter(s)
	t1 = c0 * c['0'] + c1 * c['1']
	t2 = n * c0 + h * c['1']
	t3 = n * c1 + h * c['0']
	print(min(t1, t2, t3))


t = int(input())
cases = []
for _ in range(t):
	(n, c0, c1, h) = input().split()
	(n, c0, c1, h) = (int(n), int(c0), int(c1), int(h))
	s = input()
	coins = 0
	if c1 > c0 and c1 - c0 > h:
		s = list(s)
		for (i, v) in enumerate(s):
			if v == '1':
				coins += h
				s[i] = '0'
	elif c0 > c1 and c0 - c1 > h:
		s = list(s)
		for (i, v) in enumerate(s):
			if v == '0':
				coins += h
				s[i] = '1'
	for (i, v) in enumerate(s):
		if v == '0':
			coins += c0
		elif v == '1':
			coins += c1
	print(coins)


import sys
first = True
second = False
T = int(input())
for line in sys.stdin:
	if first:
		(n, c, c1, h) = map(int, line.strip().split())
		first = False
		second = True
		continue
	if second:
		s = line.strip()
		coins = 0
		if c < c1 and c1 - c > h:
			for x in range(n):
				if s[x] == '1':
					coins += h
					coins += c
				else:
					coins += c
		elif c > c1 and c - c1 > h:
			for x in range(n):
				if s[x] == '0':
					coins += h
					coins += c1
				else:
					coins += c1
		else:
			for x in range(n):
				if s[x] == '0':
					coins += c
				else:
					coins += c1
		second = False
		first = True
	print(coins)


import sys
import math
import bisect
import functools
from functools import lru_cache
from sys import stdin, stdout
from math import gcd, floor, sqrt, log, ceil
from heapq import heappush, heappop, heapify
from collections import defaultdict as dd
from collections import Counter as cc
from bisect import bisect_left as bl
from bisect import bisect_right as br

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
sys.setrecursionlimit(100000000)
intinp = lambda : int(input().strip())
stripinp = lambda : input().strip()
fltarr = lambda : list(map(float, input().strip().split()))
intarr = lambda : list(map(int, input().strip().split()))
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
MOD = 1000000007
tests = int(input())
for test in range(tests):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	count_0 = s.count('0')
	count_1 = s.count('1')
	print(min(count_0 * c0 + count_1 * c1, count_0 * h + n * c1, count_1 * h + n * c0))
num_cases = 1
for _ in range(num_cases):
	pass


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	st = input()
	cost = 0
	cost1 = st.count('0') * c0 + st.count('1') * c1
	cost2 = st.count('0') * c0 + st.count('1') * (h + c0)
	cost3 = st.count('1') * c1 + st.count('0') * (h + c1)
	print(min(cost1, cost2, cost3))


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = [int(i) for i in input().strip()]
	if h + c0 < c1:
		print(h * s.count(1) + c0 * n)
	elif h + c1 < c0:
		print(h * s.count(0) + c1 * n)
	else:
		print(s.count(0) * c0 + s.count(1) * c1)


a = int(input())
cnt_0 = 0
cnt_1 = 0
cnt1 = 0
cnt2 = 0
by = ''
other = ''
for i in range(a):
	(n, c0, c1, h) = map(int, input().split())
	stg = input()
	cnt_0 = stg.count('0')
	cnt_1 = stg.count('1')
	cnt1 = cnt_0 * c0 + cnt_1 * c1
	if c0 > c1:
		cnt2 = n * c1 + h * cnt_0
	elif c1 > c0:
		cnt2 = n * c0 + h * cnt_1
	elif c1 == c0:
		cnt2 = n * c0
	print(min(cnt1, cnt2))


import sys
t = int(input())
while t:
	one_count = 0
	zero_count = 0
	(n, c0, c1, h) = map(int, input().split())
	entrada = input()
	zero_count = len(list(filter(lambda x: x is '0', entrada)))
	one_count = n - zero_count
	custo_inicial = zero_count * c0 + one_count * c1
	if c0 == c1:
		res = n * c0
	elif c0 > c1:
		if c1 + h < c0:
			res = n * c1 + zero_count * h
		else:
			res = custo_inicial
	elif c0 + h < c1:
		res = n * c0 + one_count * h
	else:
		res = custo_inicial
	print(res)
	t -= 1


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	strings = input()
	x = strings.count('0')
	y = strings.count('1')
	cost_1 = x * c1 + y * c1 + x * h
	cost_2 = y * c1 + x * c0
	cost_3 = y * c0 + x * c0 + y * h
	result = min(cost_1, cost_2, cost_3)
	print(result)


t = int(input())
for j in range(t):
	(n, c0, c1, h) = map(int, input().split())
	b = input()
	summ = 0
	if c0 > c1 + h:
		for i in range(n):
			if b[i] == '0':
				summ += c1
				summ += h
			else:
				summ += c1
	elif c1 > c0 + h:
		for i in range(n):
			if b[i] == '1':
				summ += c0
				summ += h
			else:
				summ += c0
	else:
		for i in range(n):
			if b[i] == '0':
				summ += c0
			else:
				summ += c1
	print(summ)


for _ in range(int(input())):
	(s, c, c1, h) = map(int, input().split())
	n = input()
	(a, a1, a2) = (0, 0, 0)
	a = n.count('0') * c + n.count('1') * c1
	a1 = s * c + n.count('1') * h
	a2 = s * c1 + n.count('0') * h
	print(min(a, a1, a2))


import math
import string
import random
from random import randrange
from collections import deque
from collections import defaultdict

def solve(n, c0, c1, h, s):
	ans = 0
	f0 = 0
	for i in range(len(s)):
		if s[i] == '0':
			f0 += 1
	f1 = n - f0
	a1 = c0 * f0 + c1 * f1
	if abs(c0 - c1) > h:
		if c0 > c1:
			ans = c1 * n + f0 * h
		else:
			ans = f1 * h + c0 * n
		print(ans)
		return
	print(a1)
	return

def main():
	t = int(input())
	while t > 0:
		t -= 1
		(x, y) = (0, 0)
		arr = []
		s = ''
		(n, c0, c1, h) = map(int, input().strip().split(' '))
		s = input().strip()
		solve(n, c0, c1, h, s)
	return

def test():
	arr_size = 25
	test_cases = 100
	min_range = -100
	max_range = 100
	str_size = 30
	step = 1
	print('<-------- DEBUG ----------->')
	for i in range(test_cases):
		k = []
		for j in range(arr_size):
			num = randrange(min_range, max_range, step)
			k.append(num)
		solve(n, arr)
	print('<-------- DEBUG ----------->')
	return
main()


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	(zero, one) = (s.count('0'), s.count('1'))
	cost_now = zero * c0 + one * c1
	cost_0 = n * c0 + one * h
	cost_1 = n * c1 + zero * h
	print(min(cost_0, cost_1, cost_now))


for t in range(int(input())):
	(n, cs, cm, h) = [*map(int, input().split())]
	s = list(input())
	cnts = s.count('0')
	cntm = s.count('1')
	if cs > cm:
		(cnts, cntm) = (cntm, cnts)
		(cs, cm) = (cm, cs)
	if h < cm - cs:
		cm = h + cs
	print(cm * cntm + cs * cnts)


t = int(input())
for i in range(t):
	[n, c0, c1, h] = list(map(int, input().split(' ')))
	s = input()
	if abs(c0 - c1) > h:
		print(n * (c0 if c1 > c0 else c1) + h * s.count('1' if c1 > c0 else '0'))
	else:
		x = s.count('0')
		print(x * c0 + (n - x) * c1)


t = int(input())
for case in range(t):
	(n, c0, c1, h) = [int(x) for x in input().split(' ')]
	s = input()
	cost = 0
	for char in s:
		if char == '0':
			cost += min(c0, c1 + h)
		else:
			cost += min(c1, c0 + h)
	print(cost)


for _ in range(int(input())):
	(n, cz, co, h) = map(int, input().split())
	b = input()
	z = b.count('0')
	o = b.count('1')
	l = len(b)
	print(min(o * co + z * cz, o * h + cz * l, z * h + co * l))


inn = lambda : int(input())
inm = lambda : map(int, input().split())
ins = lambda : str(input())
ina = lambda : list(map(int, input().split()))

def solve():
	(n, c0, c1, h) = inm()
	s = ins()
	a = 0
	b = 0
	for i in s:
		a += i == '0'
		b += i == '1'
	ans = float('inf')
	for x in range(-n, n + 1):
		if a + x > n or b - x < 0 or a + x < 0 or (b - x > n):
			continue
		ans = min(ans, c0 * (a + x) + c1 * (b - x) + h * abs(x))
	print(ans)

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


cases = int(input())
for a in range(cases):
	b = input()
	(n, c1, c2, h) = map(int, b.split(' '))
	s = str(input())
	res = 0
	if abs(c2 - c1) > h:
		if c2 > c1:
			for x in s:
				if x == '1':
					res += h
			res += n * c1
		else:
			for x in s:
				if x == '0':
					res += h
			res += n * c2
	else:
		for y in s:
			if y == '0':
				res += c1
			else:
				res += c2
	print(res)


def str_list(s, char):
	output_list = []
	collector = ''
	for i in range(len(s)):
		if s[i] == char:
			if collector:
				output_list.append(int(collector))
				collector = ''
		else:
			collector += s[i]
	output_list.append(int(collector))
	return output_list

def merge_sort(l):

	def merge(l_1, l_2):
		(i, j) = (0, 0)
		output_list = []
		while i < len(l_1) and j < len(l_2):
			if l_1[i][0] < l_2[j][0]:
				output_list.append(l_1[i])
				i += 1
			else:
				output_list.append(l_2[j])
				j += 1
		if i == len(l_1):
			output_list += l_2[j:]
		elif j == len(l_2):
			output_list += l_1[i:]
		return output_list

	def sorts(l):
		if len(l) < 2:
			return l
		else:
			mid = len(l) // 2
			left = sorts(l[:mid])
			right = sorts(l[mid:])
		return merge(left, right)
	return sorts(l)

def merge_sort2(l):

	def merge(l_1, l_2):
		(i, j) = (0, 0)
		output_list = []
		while i < len(l_1) and j < len(l_2):
			if l_1[i][1] < l_2[j][1]:
				output_list.append(l_1[i])
				i += 1
			else:
				output_list.append(l_2[j])
				j += 1
		if i == len(l_1):
			output_list += l_2[j:]
		elif j == len(l_2):
			output_list += l_1[i:]
		return output_list

	def sorts(l):
		if len(l) < 2:
			return l
		else:
			mid = len(l) // 2
			left = sorts(l[:mid])
			right = sorts(l[mid:])
		return merge(left, right)
	return sorts(l)

def str_list_with_str(s, char):
	output_list = []
	collector = ''
	for i in range(len(s)):
		if s[i] == char:
			if collector:
				output_list.append(collector)
				collector = ''
		else:
			collector += s[i]
	output_list.append(collector)
	return output_list

def list_str(l, char):
	output_str = ''
	for i in range(len(l) - 1):
		output_str += str(l[i]) + char
	output_str += str(l[len(l) - 1])
	return output_str

def find_max(l, i, current_max):
	if i == len(l):
		return current_max
	else:
		if current_max < l[i]:
			current_max = l[i]
		return find_max(l, i + 1, current_max)

def simple_find_min_max(l):
	current_max = l[0]
	current_min = l[0]
	for i in l:
		if current_max < i:
			current_max = i
		if current_min > i:
			current_min = i
	return (current_min, current_max)

def simple_find_min(l):
	current_max = l[0]
	for i in l:
		if current_max > i:
			current_max = i
	return current_max

def sum(l):
	sum = 0
	for i in l:
		sum += i
	return sum

def count_1_0(s, char):
	count_1 = 0
	for i in s:
		if i == char:
			count_1 += 1
	return count_1

def maxi(c1, c2):
	if c1 > c2:
		return c1
	return c2

def mini(c1, c2):
	if c1 < c2:
		return c1
	return c2

def main_function():
	test_cases = range(int(input()))
	output_list = []
	for test_case in test_cases:
		(n, c_0, c_1, h) = str_list(input(), ' ')
		binary_str = input()
		difference = abs(c_1 - c_0)
		max_c = maxi(c_0, c_1)
		min_c = mini(c_0, c_1)
		(count_0, count_1) = (count_1_0(binary_str, '0'), count_1_0(binary_str, '1'))
		if difference <= h:
			sum = count_0 * c_0 + count_1 * c_1
		elif c_1 > c_0:
			sum = min_c * len(binary_str) + h * count_1
		else:
			sum = min_c * len(binary_str) + h * count_0
		output_list.append(str(sum))
	return list_str(output_list, '\n')
print(main_function())


for t in range(int(input())):
	l = list(map(int, input().split()))
	n = l[0]
	c1 = l[1]
	c2 = l[2]
	h = l[3]
	s = input()
	o = 0
	z = 0
	for i in range(n):
		if s[i] == '1':
			o = o + 1
		else:
			z = z + 1
	ans1 = o * h + n * c1
	ans2 = z * h + n * c2
	ans3 = z * c1 + o * c2
	print(min(min(ans2, ans1), ans3))


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = str(input())
	one = s.count('1')
	zero = s.count('0')
	ans = zero * min(c0, c1 + h) + one * min(c1, c0 + h)
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = [int(i) for i in input() if i != '\n']
	one = s.count(1)
	zero = s.count(0)
	mina = c0 * zero + c1 * one
	change = 0
	ans = [mina]
	if c0 < c1:
		for i in s:
			if i == 1:
				change += 1
			ans.append(change * h + c0 * (zero + change) + c1 * (one - change))
	else:
		for i in s:
			if i == 0:
				change += 1
		ans.append(change * h + c0 * (zero - change) + c1 * (one + change))
	print(min(ans))


for _ in range(int(input())):
	(n, o, l, h) = map(int, input().split())
	x = list(map(int, input().strip()))
	print(x.count(0) * min(o, l + h) + x.count(1) * min(l, o + h))


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	cost = 0
	for el in s:
		if el == '0':
			if c0 > c1 + h:
				cost += c1 + h
			else:
				cost += c0
		if el == '1':
			if c1 > c0 + h:
				cost += c0 + h
			else:
				cost += c1
	print(cost)


def solve():
	(n, c0, c1, h) = [int(x) for x in input().split()]
	s = input()
	if abs(c0 - c1) <= h:
		print(s.count('0') * c0 + s.count('1') * c1)
	else:
		print(n * min(c0, c1) + h * s.count('0' if c0 > c1 else '1'))
t = int(input())
while t:
	t -= 1
	solve()


for t in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	st = 0
	s = str(input())
	if c0 + h < c1:
		for i in s:
			if i == '1':
				st += c0 + h
			else:
				st += c0
		print(st)
	elif c1 + h < c0:
		for i in s:
			if i == '1':
				st += c1
			else:
				st += c1 + h
		print(st)
	else:
		for i in s:
			if i == '1':
				st += c1
			else:
				st += c0
		print(st)


for T in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	(count1, count0) = (0, 0)
	for i in s:
		if i == '0':
			count0 += 1
		else:
			count1 += 1
	if h + c1 < c0:
		print(count1 * c1 + count0 * (h + c1))
	elif h + c0 < c1:
		print(count0 * c0 + count1 * (h + c0))
	else:
		print(count0 * c0 + count1 * c1)


for _ in range(int(input())):
	(n, c0, c1, h) = (int(x) for x in input().split())
	s = input()
	z = s.count('0')
	w = n - z
	if c1 > c0 + h:
		print(c0 * n + h * w)
	elif c0 > c1 + h:
		print(c1 * n + h * z)
	else:
		print(c0 * z + c1 * w)


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

def i():
	return int(input())
for _ in range(i()):
	(n, c0, c1, h) = mp()
	s = input()
	a = s.count('1')
	b = s.count('0')
	x = min(c1 * a, (c0 + h) * a)
	y = min(c0 * b, (c1 + h) * b)
	print(x + y)


t = int(input())
for i in range(0, t):
	(n, s0, s1, h) = map(int, input().split())
	string = list(input())
	string = list(map(lambda x: int(x), string))
	zeros = string.count(0)
	ones = string.count(1)
	if s0 == h and s1 == h or (h > s0 and h > s1):
		print(zeros * s0 + ones * s1)
	else:
		t = min(s0, s1)
		on = 0
		if t == s1:
			on = 1
		if on == 0:
			ans = ones * h + n * s0
		else:
			ans = zeros * h + n * s1
		ans = min(ans, zeros * s0 + ones * s1)
		print(ans)


for i in range(int(input())):
	lst = list(map(int, input().split()))
	(n, c0, c1, h) = (lst[0], lst[1], lst[2], lst[3])
	s = input()
	s1 = s.count('1')
	s0 = s.count('0')
	if c1 == c0:
		print(n * c1)
	elif c0 > c1 and h > c0 - c1:
		print(c1 * s1 + c0 * s0)
	elif c1 > c0 and h > c1 - c0:
		print(c1 * s1 + c0 * s0)
	elif c0 > c1 and c0 > h:
		print(n * c1 + h * s.count('0'))
	elif c1 > c0 and c1 > h:
		print(n * c0 + h * s.count('1'))
	elif h > c1 and h > c0:
		print(c1 * s1 + c0 * s0)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	if h < abs(c0 - c1):
		print([n * c0 + h * s.count('1'), s.count('0') * h + c1 * n][c0 > c1])
	else:
		print(s.count('0') * c0 + c1 * s.count('1'))


t = int(input())
for i in range(t):
	(n, c0, c1, h) = list(map(int, input().split()))
	s = input()
	count = 0
	count_0 = s.count('0')
	count_1 = s.count('1')
	if c0 * count_0 > count_0 * (c1 + h):
		count += count_0 * (c1 + h)
	if c0 * count_0 <= count_0 * (c1 + h):
		count += c0 * count_0
	if c1 * count_1 > count_1 * (c0 + h):
		count += count_1 * (c0 + h)
	if c1 * count_1 <= count_1 * (c0 + h):
		count += c1 * count_1
	print(count)


t = int(input())
for i in range(t):
	p = int(0)
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	arr = [int(d) for d in str(s)]
	total = int(0)
	total2 = int(0)
	z = int(0)
	k = int(0)
	if c0 > c1:
		for j in range(n):
			if arr[j] == 0:
				p = p + 1
		total = p * h + n * c1
	elif c1 > c0:
		for j in range(n):
			if arr[j] == 1:
				p = p + 1
		total = n * c0 + p * h
	elif c0 == c1:
		total = n * c0
	for j in range(n):
		if arr[j] == 0:
			k = k + 1
		elif arr[j] == 1:
			z = z + 1
		total2 = k * c0 + z * c1
	if total <= total2:
		print(total)
	else:
		print(total2)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
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')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=300006, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	(n, c0, c1, c2) = map(int, input().split())
	s = input()
	an = s.count('0')
	ans = an * min(c0, c2 + c1) + (n - an) * min(c1, c2 + c0)
	print(ans)


test_case = int(input())
for i in range(test_case):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	count_0 = 0
	count_1 = 0
	for char in s:
		if char == '0':
			count_0 += 1
	count_1 = n - count_0
	if c0 == c1:
		print(n * c0)
		continue
	temp = 0
	if c0 < c1:
		temp = c0 * count_0
		if temp + count_1 * c0 + count_1 * h <= count_1 * c1 + temp:
			print(temp + count_1 * c0 + count_1 * h)
		else:
			print(count_1 * c1 + temp)
	else:
		temp = c1 * count_1
		if temp + c1 * count_0 + h * count_0 <= temp + c0 * count_0:
			print(temp + c1 * count_0 + h * count_0)
		else:
			print(temp + c0 * count_0)


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	zero = s.count('0')
	one = s.count('1')
	ans = zero * c0 + one * c1
	for i in range(1, zero + 1):
		other = i * h + (one + i) * c1 + (zero - i) * c0
		ans = min(other, ans)
	for i in range(1, one + 1):
		other = i * h + (one - i) * c1 + (zero + i) * c0
		ans = min(other, ans)
	print(ans)


for t in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	_0 = s.count('0')
	_1 = s.count('1')
	print(min(c0 * _0 + c1 * _1, c0 * len(s) + h * _1, c1 * len(s) + h * _0))


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	temp = c0 * s.count('0') + c1 * s.count('1')
	if c0 == c1:
		print(temp)
	elif c0 > c1:
		c = s.count('0')
		for i in range(n):
			if s[i] == '0':
				s = s.replace(s[i], '1')
		cost = c * h + s.count('1') * c1
		print(min(temp, cost))
	else:
		c = s.count('1')
		for i in range(n):
			if s[i] == '1':
				s = s.replace(s[i], '0')
		cost = c * h + s.count('0') * c0
		print(min(temp, cost))


I = input
exec(int(I()) * 'n,*c,h=map(int,I().split());print(sum(min(c[i],c[i^1]+h)for i in map(int,I())));')


def number_of_1(binary):
	binary = list(binary)
	numb_of_1 = 0
	for i in binary:
		if i == '1':
			numb_of_1 += 1
	return numb_of_1

def number_of_0(binary):
	binary = list(binary)
	numb_of_0 = 0
	for i in binary:
		if i == '0':
			numb_of_0 += 1
	return numb_of_0
n = int(input())
for i in range(n):
	(n, c0, c1, h) = input().split()
	c0 = int(c0)
	c1 = int(c1)
	h = int(h)
	binary = input()
	numb_of_0 = number_of_0(binary)
	numb_of_1 = number_of_1(binary)
	answer = 0
	if c0 < h + c1:
		answer = answer + c0 * numb_of_0
	else:
		answer = answer + (c1 + h) * numb_of_0
	if c1 < h + c0:
		answer = answer + c1 * numb_of_1
	else:
		answer = answer + (c0 + h) * numb_of_1
	print(answer)


for __ in range(int(input())):
	(n, a, b, h) = list(map(int, input().split()))
	ar = list(map(int, input()))
	if a < b:
		if b - a > h:
			print(n * a + h * ar.count(1))
		else:
			print(ar.count(0) * a + ar.count(1) * b)
	elif a - b > h:
		print(n * b + h * ar.count(0))
	else:
		print(ar.count(0) * a + ar.count(1) * b)


ans = []
for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	u = list(map(int, list(input())))
	c0 = min(c0, c1 + h)
	c1 = min(c1, c0 + h)
	cur = 0
	for i in range(n):
		if u[i] == 0:
			cur += c0
		else:
			cur += c1
	ans.append(cur)
print(*ans, sep='\n')


def main():
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	print(min(s.count('0') * c0 + s.count('1') * c1, s.count('0') * h + len(s) * c1, s.count('1') * h + len(s) * c0))
from math import *
for test in range(int(input())):
	main()


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	cost = [c0, c1]
	ans = 0
	for c in input():
		i = int(c)
		ans += min(cost[i], cost[(i + 1) % 2] + h)
	print(ans)


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	diff0 = c0 - h
	diff1 = c1 - h
	s = input()
	zc = 0
	oc = 0
	for i in s:
		if i == '0':
			zc += 1
		else:
			oc += 1
	ans = 0
	if c0 + h <= c1:
		ans = c0 * zc + oc * (c0 + h)
	elif c1 + h <= c0:
		ans = zc * (c1 + h) + oc * c1
	else:
		ans = zc * c0 + oc * c1
	print(ans)


from math import *
from bisect import bisect_left as bl
from bisect import bisect_right as br
from collections import Counter as ctr
from collections import deque as dq
from array import array
from re import search
li = lambda : list(map(int, input().split()))
arr = lambda a: array('i', a)
bi = lambda n: bin(n).replace('0b', '')
yn = lambda f: print('NYOE S'[f::2])
sbstr = lambda a, s: search('.*'.join(a), s)

def solve():
	for _ in range(int(input())):
		(n, c0, c1, h) = li()
		s = input()
		cost = 0
		if h < c0 - c1:
			print(s.count('0') * h + c1 * n)
		elif h < c1 - c0:
			print(s.count('1') * h + c0 * n)
		else:
			print(s.count('0') * c0 + s.count('1') * c1)
solve()


for t in range(int(input())):
	(n, c0, c1, h) = map(int, input().strip().split())
	string = str(input()[:n])
	ans = 0
	for l in string:
		if l == '0':
			ans += min(c0, c1 + h)
		if l == '1':
			ans += min(c1, c0 + h)
	print(ans)


def count(s, ch):
	c = 0
	for i in s:
		if i == ch:
			c += 1
	return c

def min(numlist):
	min = numlist[0]
	for i in numlist:
		if i < min:
			min = i
	return min
n = eval(input())
res = []
for i in range(n):
	cost = 0
	(n, c0, c1, h) = (int(i) for i in str(input()).split())
	s = input()
	n0 = count(s, '0')
	n1 = count(s, '1')
	if c0 < c1:
		tmp_res = []
		for z in range(n1 + 1):
			tmp_res.append((n0 + z) * c0 + (n1 - z) * c1 + h * z)
		cost += min(tmp_res)
	elif c0 > c1:
		tmp_res = []
		for z in range(n0 + 1):
			tmp_res.append((n1 + z) * c1 + (n0 - z) * c0 + h * z)
		cost += min(tmp_res)
	else:
		cost += (n0 + n1) * c0
	res.append(cost)
for i in res:
	print(i)


t = int(input())
while t:
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	a = s.count('1') * c1
	b = s.count('0') * c0
	df = a + b
	if c1 > c0:
		ans1 = s.count('1') * h
		ab = ans1 + n * c0
		print(min(df, ab))
	elif c1 < c0:
		ans1 = s.count('0') * h
		ab = ans1 + n * c1
		print(min(df, ab))
	elif c1 == c0:
		print(df)
	t -= 1


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	z0 = s.count('0')
	z1 = s.count('1')
	print(min(z0 * c0 + z1 * c1, z1 * h + n * c0, z0 * h + n * c1))


def result():
	ele = list(map(int, input().split()))
	string = input()
	zero = string.count('0')
	one = string.count('1')
	difference = abs(ele[1] - ele[2])
	if difference > ele[3]:
		if ele[1] > ele[2]:
			print(ele[0] * ele[2] + zero * ele[3])
		else:
			print(ele[0] * ele[1] + one * ele[3])
	else:
		total = zero * ele[1] + one * ele[2]
		print(total)
for i in range(int(input())):
	result()


t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	s0 = 0
	s1 = 0
	for x in s:
		if x == '0':
			s0 += 1
		else:
			s1 += 1
	sum1 = s0 * c0 + s1 * c1
	sum2 = s0 * (c1 + h) + s1 * c1
	sum3 = s0 * c0 + s1 * (c0 + h)
	print(min(sum1, sum2, sum3))


x = int(input())
for _ in range(x):
	(n, c, b, a) = [int(i) for i in input().split()]
	s = input()
	x = s.count('0') * min(a + b, c) + s.count('1') * min(a + c, b)
	print(x)


for i in range(int(input())):
	(n, c, c1, h) = map(int, input().split())
	cnt1 = 0
	cnt2 = 0
	s = list(input())
	for i in range(n):
		if s[i] == '0':
			cnt1 += 1
		else:
			cnt2 += 1
	if c + h < c1:
		cnt1 = n
		print(n * c + cnt2 * h)
	elif c1 + h < c:
		print(c1 * n + cnt1 * h)
	else:
		print(cnt1 * c + cnt2 * c1)


t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	nbMax = 0
	zeros = 0
	ones = 0
	if c0 < c1:
		maxNum = c1
		minNum = c0
	else:
		minNum = c1
		maxNum = c0
	for i in range(n):
		if s[i] == '0':
			zeros += 1
		else:
			ones += 1
	if h + minNum < maxNum:
		if maxNum == c1:
			print(ones * (h + minNum) + zeros * minNum)
		else:
			print(zeros * (h + minNum) + ones * minNum)
	else:
		print(zeros * c0 + ones * c1)


import io, os
import sys
from sys import stdin
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, namedtuple
from math import gcd, ceil, floor, factorial
from itertools import combinations, permutations
input = sys.stdin.readline

def work():
	ans = 0
	return

def main():
	test = int(input())
	for idt in range(test):
		(n, c0, c1, h) = map(int, input().split())
		s = input().strip('\r\n')
		ans = 0
		for (i, ch) in enumerate(s):
			if ch == '0':
				ans += min(c0, c1 + h)
			else:
				ans += min(c1, c0 + h)
		print(ans)
	return
main()


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	price_base = 0
	price = []
	for i in s:
		if i == '0':
			price_base += c0
		else:
			price_base += c1
	price.append(price_base)
	n_0 = s.count('0')
	n_1 = s.count('1')
	ss = s[:]
	for i in range(1, n_0 + 1):
		p = price_base + i * h - i * c0 + i * c1
		price.append(p) if p >= 0 else None
	ss = s[:]
	for i in range(1, n_1 + 1):
		p = price_base + i * h - i * c1 + i * c0
		price.append(p) if p >= 0 else None
	print(min(price))


t = int(input())
for w in range(t):
	ch1 = input()
	L1 = [int(i) for i in ch1.split()]
	cmin = min(L1[1], L1[2])
	cmax = max(L1[1], L1[2])
	n = L1.pop(0)
	if L1.index(cmin) == 0:
		bmin = '0'
		bmax = '1'
	else:
		bmin = '1'
		bmax = '0'
	ch2 = input()
	if cmin + L1[2] < cmax:
		print(ch2.count(bmax) * (cmin + L1[2]) + ch2.count(bmin) * cmin)
	else:
		print(ch2.count(bmax) * cmax + ch2.count(bmin) * cmin)


t = int(input())
for i in range(t):
	(n, c0, c1, h) = list(map(int, input().split(' ')))
	s = input()
	if c0 > c1 + h:
		c0 = c1 + h
	elif c1 > c0 + h:
		c1 = c0 + h
	ans = 0
	for x in s:
		if x == '0':
			ans = ans + c0
		else:
			ans = ans + c1
	print(ans)


t = int(input())
while t > 0:
	(n, c0, c1, h) = [int(x) for x in input().split(' ')]
	s = input()
	cost = 0
	num_0 = 0
	num_1 = 0
	for c in s:
		if c == '0':
			cost += c0
			num_0 += 1
		else:
			cost += c1
			num_1 += 1
	if abs(c1 - c0) > h:
		if c1 > c0:
			cost += h * num_1 - num_1 * c1 + num_1 * c0
		else:
			cost += h * num_0 - num_0 * c0 + num_0 * c1
	print(cost)
	t -= 1


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	arr = list(map(int, input()))
	count0 = arr.count(0)
	count1 = n - count0
	nc = count1 * c1 + count0 * c0
	if count1 * h + n * c0 < nc:
		print(n * c0 + count1 * h)
	elif count0 * h + n * c1 < nc:
		print(count1 * c1 + count0 * h + count0 * c1)
	else:
		print(count0 * c0 + count1 * c1)


def chCounter(str, ch):
	counter = 0
	for i in str:
		if i == ch:
			counter += 1
	return counter

def costCalculator(str, c0, c1, h):
	zeros = chCounter(str, '0')
	ones = chCounter(str, '1')
	if c0 > c1:
		if c1 + h < c0:
			c0 = c1 + h
	elif c1 > c0:
		if c0 + h < c1:
			c1 = c0 + h
	cost = zeros * c0 + ones * c1
	return cost

def main():
	Count = int(input())
	for i in range(Count):
		(n, c0, c1, h) = map(int, input().split())
		str = input()
		print(costCalculator(str, c0, c1, h))
main()


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = str(input())
	k = n * c0 + s.count('1') * h
	l = n * c1 + s.count('0') * h
	m = s.count('0') * c0 + s.count('1') * c1
	print(min(k, l, m))


t = int(input())
for i in range(t):
	(n, c0, c1, h) = input().split()
	(n, c0, c1, h) = (int(n), int(c0), int(c1), int(h))
	s = input()
	su = 0
	for i in s:
		if int(i) == 1:
			if c1 < c0 + h:
				su += c1
			else:
				su += c0 + h
		elif int(i) == 0:
			if c0 < c1 + h:
				su += c0
			else:
				su += c1 + h
	print(su)


for t in range(int(input())):
	(n, c1, c2, h) = [int(k) for k in input().split()]
	z = 0
	o = 0
	s = input()
	for ele in s:
		if ele == '0':
			z += 1
		else:
			o += 1
	print(min(n * c1 + o * h, n * c2 + z * h, z * c1 + o * c2))


t = int(input())
for i in range(t):
	(n, c0, c1, h) = [int(j) for j in input().split()]
	binary_string = input()
	result = 0
	for i in range(len(binary_string)):
		if binary_string[i] == '0':
			result += min(c0, c1 + h)
		else:
			result += min(c1, c0 + h)
	print(result)


t = int(input())

def Total(lst, a, b):
	total = 0
	for i in lst:
		if i == '0':
			total += a
		else:
			total += b
	return total
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = list(input())
	large = 0
	small = 0
	total = Total(s, c0, c1)
	changes = 0
	if c0 > c1:
		large = '0'
		small = '1'
	elif c1 > c0:
		large = '1'
		small = '0'
	else:
		print(Total(s, c0, c1))
		continue
	for i in s:
		if i == large:
			s[s.index(large)] = small
			if total > Total(s, c0, c1) + h + changes * h:
				changes += 1
				total = Total(s, c0, c1) + changes * h
			else:
				s[s.index(small)] = large
	print(total)


def solution():
	(n, c0, c1, h) = map(int, input().split())
	s = list(input())
	cnt1 = 0
	cnt0 = 0
	for i in range(n):
		if s[i] == '0':
			cnt0 += 1
		else:
			cnt1 += 1
	ans = cnt1 * c1 + cnt0 * c0
	for i in range(0, cnt0 + 1):
		x = (cnt0 - i) * c0 + (cnt1 + i) * c1 + h * i
		ans = min(ans, x)
	for i in range(0, cnt1 + 1):
		x = (cnt0 + i) * c0 + (cnt1 - i) * c1 + h * i
		ans = min(ans, x)
	print(ans)
t = int(input())
for _ in range(t):
	solution()


for y in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	val = input()
	new = []
	final_cost = 0
	for y in val:
		x = int(y)
		new.append(x)
	if d < c or d < b:
		if c < b and c + d < b:
			conversion_cost = d * new.count(0)
			final_cost = c * a + conversion_cost
		elif b < c and b + d < c:
			conversion_cost = d * new.count(1)
			final_cost = b * a + conversion_cost
		elif b == c:
			final_cost = b * a
		else:
			final_cost = new.count(0) * b + new.count(1) * c
	else:
		final_cost = new.count(0) * b + new.count(1) * c
	print(final_cost)


t = int(input(''))
for i in range(t):
	(n, c0, c1, h) = map(int, input('').split())
	s = input('')
	if c0 > c1:
		d = s.count('1')
		b = s.count('0')
		c = c1
		a = c0
	else:
		d = s.count('0')
		b = s.count('1')
		c = c0
		a = c1
	Min = 100000000
	for j in range(0, b + 1):
		Min = min(Min, j * h + (d + j) * c + (b - j) * a)
	print(Min)


for tc in range(int(input())):
	(n, c0, c1, k) = map(int, input().split())
	string = input()
	if c0 == c1:
		print(n * c0)
	elif c0 < c1:
		zero = string.count('0')
		ones = string.count('1')
		ans = [zero * c0 + ones * c1]
		temp = ones * k
		ans.append(temp + n * c0)
		print(min(ans))
	else:
		zero = string.count('0')
		ones = string.count('1')
		ans = [zero * c0 + ones * c1]
		temp = zero * k
		ans.append(temp + n * c1)
		print(min(ans))


from sys import stdin
I = stdin.readline
for _ in range(int(I())):
	(n, c0, c1, h) = map(int, I().split())
	mn = None
	ar = I()
	one = ar.count('1')
	zero = ar.count('0')
	for i in range(n + 1):
		cost = i * c0 + (n - i) * c1
		chg = one
		fl = 1
		if zero > i:
			chg = zero
			fl = 0
		elif zero == i:
			fl = 3
		if fl == 0:
			cost += (chg - i) * h
		elif fl == 1:
			cost += (chg - (n - i)) * h
		if mn == None or cost < mn:
			mn = cost
	print(mn)


t = int(input())
for i in range(t):
	(n, c, c1, h) = map(int, input().split())
	s = input()
	k1 = 0
	k2 = 0
	for j in range(n):
		if s[j] == '0':
			k1 = k1 + 1
		else:
			k2 = k2 + 1
	if c > c1 and c1 + h < c:
		k1 = (c1 + h) * k1
		k2 = k2 * c1
	elif c < c1 and c + h < c1:
		k1 = k1 * c
		k2 = (c + h) * k2
	else:
		k1 = k1 * c
		k2 = k2 * c1
	print(k1 + k2)


for i in range(int(input())):
	(n, a, b, c) = map(int, input().split())
	k = input().strip()
	cnt = 0
	if abs(a - b) <= c:
		for j in k:
			if j == '0':
				cnt += a
			else:
				cnt += b
	elif a > b:
		for j in k:
			if j == '0':
				cnt += c + b
			else:
				cnt += b
	else:
		for j in k:
			if j == '0':
				cnt += a
			else:
				cnt += c + a
	print(cnt)


import os.path
import sys
from math import *
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def inp():
	return sys.stdin.readline().strip()
for _ in range(int(inp())):
	(n, a, b, h) = map(int, inp().split())
	s = inp()
	ans = 0
	(x, y) = (0, 0)
	for i in range(n):
		if s[i] == '0':
			x = a
			y = h + b
		elif s[i] == '1':
			x = b
			y = h + a
		ans += min(x, y)
	print(ans)


from collections import Counter
import math
import sys
import heapq
from bisect import bisect, bisect_left, bisect_right

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

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def mod():
	return 10 ** 9 + 7
for i in range(INT()):
	(n, c0, c1, h) = MAP()
	s = input()
	count0 = s.count('0')
	count1 = s.count('1')
	ans = count0 * c0 + count1 * c1
	if c0 < c1:
		for i in range(1, count1 + 1):
			ans = min(ans, (count0 + i) * c0 + (count1 - i) * c1 + h * i)
	else:
		for i in range(1, count0 + 1):
			ans = min((count1 + i) * c1 + (count0 - i) * c0 + h * i, ans)
	print(ans)


import os
import sys
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()

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

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

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	(n, c0, c1, h) = RL()
	s = input().strip()
	a = s.count('1')
	b = n - a
	print(min(a * c1 + b * c0, n * c0 + h * a, n * c1 + h * b))


test = int(input())
for t in range(test):
	var = [int(x) for x in input().split()]
	n = var[0]
	a = var[1]
	b = var[2]
	h = var[3]
	s = input()
	z = s.count('0')
	o = s.count('1')
	x = a * z + b * o
	y = n * a + h * o
	w = n * b + h * z
	print('                ' + str(min(x, y, w)))


n = int(input())
alist = []
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	ldr = str(input())
	if b == c:
		alist.append(b * len(ldr))
	else:
		amin = min(b, c)
		amax = max(b, c)
		if amax - amin <= d:
			alist.append(b * ldr.count(str(0)) + c * ldr.count(str(1)))
		else:
			if b > c:
				wza = 0
			elif b < c:
				wza = 1
			alist.append(amin * len(ldr) + d * ldr.count(str(wza)))
for i in alist:
	print(i)


test = int(input())
while test > 0:
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	one = s.count('1')
	zero = s.count('0')
	if c0 == c1:
		print(c0 * n)
	else:
		cost = one * c1 + zero * c0
		mincost = min(cost, one * h + c0 * n, c1 * n + zero * h)
		print(mincost)
	test -= 1


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	cnt_z = s.count('0')
	cnt_o = s.count('1')
	cost1 = 0
	cost2 = 0
	cost1 = cnt_z * c0 + cnt_o * c1
	if c0 <= c1:
		cost2 = c0 * n + cnt_o * h
	elif c1 < c0:
		cost2 = c1 * n + cnt_z * h
	if cost2 == 0:
		print(cost1)
	else:
		print(min(cost1, cost2))


import sys
from collections import Counter
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	count0 = s.count(b'0')
	count1 = s.count(b'1')
	cost = min(c0 * count0 + c1 * count1, c0 * n + count1 * h, c1 * n + count0 * h)
	print(cost)


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
S = lambda : list(map(str, input().split()))
(t,) = I()
for t1 in range(t):
	(n, c0, c1, h) = I()
	s = list(str(input()))[:-1]
	count0 = 0
	count1 = 0
	for i in range(len(s)):
		if s[i] == '1':
			count1 = count1 + 1
		else:
			count0 = count0 + 1
	if c0 > c1:
		if h + c1 < c0:
			print(n * c1 + h * count0)
		else:
			print(count0 * c0 + count1 * c1)
	elif h + c0 < c1:
		print(n * c0 + h * count1)
	else:
		print(count0 * c0 + count1 * c1)


t = int(input())
for i in range(0, t):
	p = list(map(int, input().split()))
	n = p[0]
	c_0 = p[1]
	c_1 = p[2]
	h = p[3]
	b = list(str(input()))
	b_0 = 0
	b_1 = 0
	for j in range(0, len(b)):
		if int(b[j]) == 0:
			b_0 += 1
		else:
			b_1 += 1
	cost = b_0 * c_0 + b_1 * c_1
	if h + min(c_0, c_1) >= max(c_0, c_1):
		print(cost)
	else:
		if h + c_1 < c_0:
			cost = c_1 * (b_1 + b_0) + b_0 * h
			print(cost)
		if h + c_0 < c_1:
			cost = c_0 * (b_1 + b_0) + b_1 * h
			print(cost)


from collections import Counter
t = int(input())
for _ in range(t):
	(n, a, b, h) = map(int, input().split())
	s = input()
	s = list(map(int, s))
	coins = 0
	c = Counter(s)
	coins = min(c[0] * a + c[1] * b, (c[0] + c[1]) * b + c[0] * h, (c[0] + c[1]) * a + c[1] * h)
	print(coins)


def main():
	t = int(input())
	for i in range(t):
		[n, c0, c1, h] = list(map(int, input().split()))
		count = 0
		for char in input():
			if char == '1':
				count += 1
		print(count * min(c1, c0 + h) + (n - count) * min(c0, c1 + h))
main()


import math
from collections import Counter, defaultdict, deque

def f(n, c0, c1, h, s):
	n0 = n1 = 0
	for i in range(n):
		if s[i] == '0':
			n0 += 1
		else:
			n1 += 1
	if c0 == c1:
		return c0 * n0 + c1 * n1
	else:
		ans = n0 * c0 + n1 * c1
		if c1 > c0:
			f = c0 - c1 + h
			for x in range(0, n1 + 1):
				ans = min(ans, n0 * c0 + n1 * c1 + f * x)
		else:
			f = c1 - c0 + h
			for x in range(0, n0 + 1):
				ans = min(ans, n0 * c0 + n1 * c1 + f * x)
	return ans
t = int(input())
result = []
for i in range(t):
	(n, c0, c1, h) = list(map(int, input().split()))
	s = input().strip()
	result.append(f(n, c0, c1, h, s))
for i in range(t):
	print(result[i])


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	count0 = s.count('0')
	count1 = n - count0
	ans1 = c0 * count0 + c1 * count1
	if c0 > c1 and h < c0:
		ans2 = c1 * n + h * count0
	elif c1 > c0 and h < c1:
		ans2 = c0 * n + h * count1
	else:
		ans2 = ans1
	print(min(ans1, ans2))


t = int(input())
for _ in range(1, t + 1):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	l0 = s.count('0')
	l1 = n - l0
	if c0 < c1:
		print(c0 * l0 + l1 * min(h + c0, c1))
	else:
		print(c1 * l1 + l0 * min(h + c1, c0))


def mincost(s, n, x, y, h):
	cost = 0
	if x < y:
		for i in range(n):
			if s[i] == '0':
				cost += x
			elif x + h < y:
				cost += x + h
			else:
				cost += y
	else:
		for i in range(n):
			if s[i] == '1':
				cost += y
			elif y + h < x:
				cost += y + h
			else:
				cost += x
	return cost
t = int(input())
for i in range(t):
	(n, x, y, h) = map(int, input().split())
	s = input()
	print(mincost(s, n, x, y, h))


t = int(input())
for _ in range(t):
	(n, c0, c1, h) = [int(i) for i in input().split()]
	s = input()
	zeros = 0
	ones = 0
	coins = 0
	remain = 0
	exp = 0
	chp = 0
	for c in s:
		if c is '0':
			zeros += 1
		else:
			ones += 1
	if c0 > c1:
		coins += ones * c1
		exp = c0
		chp = c1
		remain = zeros
	elif c0 < c1:
		coins += zeros * c0
		exp = c1
		chp = c0
		remain = ones
	else:
		coins = zeros * c0 + ones * c1
		print(coins)
		continue
	if exp * remain < remain * (chp + h):
		coins += exp * remain
	else:
		coins += remain * (chp + h)
	print(coins)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	s = input()
	e = f = 0
	for i in s:
		if i == '0':
			e = e + 1
		else:
			f = f + 1
	if b + d < c:
		print(b * e + (b + d) * f)
	elif c + d < b:
		print(c * f + (c + d) * e)
	else:
		print(c * f + b * e)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	(zeros, ones) = (s.count('0'), s.count('1'))
	cost_now = zeros * c0 + ones * c1
	cost_0 = n * c0 + ones * h
	cost_1 = n * c1 + zeros * h
	print(min(cost_now, cost_0, cost_1))


for i in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	c = s.count('0')
	a = s.count('1')
	print(min(c * c0 + a * c1, n * c0 + h * a, h * c + c1 * n))


t = int(input())
for i in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = str(input())
	Mi = min(c0, c1)
	Ma = max(c0, c1)
	if Mi + h < Ma:
		if Mi == c0:
			print(s.count('0') * c0 + s.count('1') * (c0 + h))
		else:
			print(s.count('0') * (c1 + h) + s.count('1') * c1)
	else:
		print(s.count('0') * c0 + s.count('1') * c1)


def main():
	(n, c0, c1, h) = map(int, input().split())
	(c0, c1) = (min(c0, c1 + h), min(c1, c0 + h))
	res = 0
	cost = {'0': c0, '1': c1}
	for a in input():
		res += cost[a]
	print(res)
t = int(input())
for _ in range(t):
	main()


t = int(input())
for i in range(t):
	(n, c0, c1, h) = [int(x) for x in input().split()]
	s = input()
	z = s.count('0')
	o = s.count('1')
	if c0 == c1:
		print(c0 * len(s))
	elif c1 > c0:
		k = z * c0 + o * c1
		m = z * c0 + o * c0 + o * h
		if k <= m:
			print(k)
		else:
			print(m)
	elif c0 > c1:
		k = z * c0 + o * c1
		m = z * h + z * c1 + o * c1
		if k <= m:
			print(k)
		else:
			print(m)


import math

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

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	(countzero, countone) = (0, 0)
	for i in range(n):
		if s[i] == '0':
			countzero += 1
		else:
			countone += 1
	a = countone * c1 + countzero * c0
	b = h * countone + n * c0
	c = h * countzero + n * c1
	print(min(a, b, c))


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	l = input()
	count0 = l.count('0')
	count1 = l.count('1')
	g = count0 * c0 + count1 * c1
	m = count1 * c1
	r = h * count1 + c0 * len(l)
	op = h * count0 + c1 * len(l)
	if g <= r and g <= op:
		print(g)
	elif r < op:
		print(r)
	else:
		print(op)


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()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

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

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res) % MOD

def comb(n, x):
	(a, b) = (1, 1)
	for i in range(1, x + 1):
		a *= n + 1 - i
		b *= i
	return a // b % MOD

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

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

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
small = 'abcdefghijklmnopqrstuvwxyz'
large = small.upper()
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve():
	(n, c0, c1, h) = read()
	s = string()
	zeroes = s.count('0')
	ones = s.count('1')
	ans1 = zeroes * c0 + ones * c1
	ans2 = zeroes * c0 + ones * (h + c0)
	ans3 = zeroes * (c1 + h) + ones * c1
	print(min(ans1, min(ans2, ans3)))
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')
t = scanner()
for i in range(t):
	solve()


n_tests = int(input())
for test in range(n_tests):
	(length, c0_coins, c1_coins, change_coins) = [int(i) for i in input().split()]
	text = input()
	cost = 0
	for char in text:
		cost += min(change_coins + c0_coins, c1_coins) if char == '1' else min(change_coins + c1_coins, c0_coins)
	print(cost)


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	n = input()
	ans = 0
	for i in n:
		if i == '0':
			ans += min(d + c, b)
		elif i == '1':
			ans += min(d + b, c)
	print(ans)


t = int(input())
for _ in range(t):
	(n, a, b, h) = map(int, input().split())
	s = list(input())
	k = s.count('1')
	m = s.count('0')
	if a == b:
		print(a * n)
	else:
		p = m * a + k * b
		q = m * h + n * b
		r = k * h + n * a
		ans = min(p, q, r)
		print(ans)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	s0 = s.count('0')
	s1 = s.count('1')
	a1 = c0 * s0 + c1 * s1
	a2 = c0 * s0 + s1 * (c0 + h)
	a3 = c1 * s1 + s0 * (c1 + h)
	ans = min(a1, a2, a3)
	print(ans)


from collections import Counter
for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	s = input()
	if c0 == c1:
		print(c0 * n)
	else:
		d = Counter(s)
		if len(d) == 1:
			if '0' in d:
				a = c0 * d['0']
				b = (c1 + h) * d['0']
				print(min(a, b))
			else:
				a = c1 * d['1']
				b = (c0 + h) * d['1']
				print(min(a, b))
		else:
			a = (c1 + h) * d['0'] + c1 * d['1']
			b = (c0 + h) * d['1'] + c0 * d['0']
			c = c0 * d['0'] + c1 * d['1']
			print(min(a, b, c))


n = int(input())
for i in range(n):
	(n1, c0, c1, h) = map(int, input().split())
	s = input()
	cnt0 = s.count('0')
	cnt1 = s.count('1')
	if c0 == c1:
		print(c0 * n1)
	elif c0 < c1:
		s0 = c0 * n1 + h * cnt1
		s00 = c0 * cnt0 + c1 * cnt1
		print(min(s0, s00))
	elif c0 > c1:
		s1 = c1 * n1 + h * cnt0
		s11 = c1 * cnt1 + c0 * cnt0
		print(min(s1, s11))


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

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

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

def invr():
	return map(int, input().split())
y = inp()
for _ in range(y):
	l = inlt()
	s = insr()
	zero = 0
	one = 0
	for x in s:
		if x == '0':
			zero += 1
		else:
			one += 1
	cost = l[1] * zero + l[2] * one
	if l[1] <= l[2]:
		if cost > one * l[3] + len(s) * l[1]:
			print(one * l[3] + len(s) * l[1])
		else:
			print(cost)
	elif l[2] < l[1]:
		if cost > zero * l[3] + len(s) * l[2]:
			print(zero * l[3] + len(s) * l[2])
		else:
			print(cost)
	else:
		print(cost)


iter = int(input())
for i in range(iter):
	price = 0
	(n, c0, c1, h) = [int(i) for i in input().split(' ')]
	binaryLine = input()
	for s in binaryLine:
		if s == '1':
			if c1 <= c0 + h:
				price += c1
			else:
				price += c0 + h
		elif c0 <= c1 + h:
			price += c0
		else:
			price += c1 + h
	print(price)


for t in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	a = input()
	zero = a.count('0')
	one = n - zero
	m = zero * c0 + one * c1
	if c1 > c0:
		z = one
		x = c0
		y = c1
	else:
		z = zero
		x = c1
		y = c0
	temp = m
	while 1:
		if z == 0 or temp > m:
			break
		temp = m - y + x + h
		z -= 1
		if temp < m:
			m = temp
	print(m)


import sys
read = sys.stdin.readline
write = sys.stdout.write
testCaseCount = int(read())
testCases = []
i = 0
while i < testCaseCount:
	testCases.append([read()[0:-1], read()[0:-1]])
	i = i + 1
for caseNum in range(testCaseCount):
	(strLen, price0, price1, changePrice) = map(int, testCases[caseNum][0].split())
	num0 = 0
	num1 = 0
	cost = 0
	for i in range(strLen):
		if testCases[caseNum][1][i] == '0':
			num0 += 1
		if testCases[caseNum][1][i] == '1':
			num1 += 1
	if price0 - price1 > changePrice:
		cost = price1 * (num0 + num1) + num0 * changePrice
	elif price1 - price0 > changePrice:
		cost = price0 * (num0 + num1) + num1 * changePrice
	else:
		cost = price0 * num0 + price1 * num1
	write(str(cost) + '\n')


def main():
	for _ in range(int(input())):
		(n, c0, c1, h) = map(int, input().split())
		s = input()
		one = s.count('1')
		zero = s.count('0')
		if c0 == c1:
			print(c0 * n)
		elif c0 < c1:
			s = c0 * zero
			s += min(h * one + c0 * one, c1 * one)
			print(s)
		else:
			s = c1 * one
			s += min(h * zero + c1 * zero, c0 * zero)
			print(s)
main()


for ad in range(int(input())):
	(n, c0, c1, h) = list(map(int, input().split()))
	s = list(input())
	zero = s.count('0')
	one = s.count('1')
	if max(c0, c1) < h + min(c0, c1):
		ans = zero * c0 + one * c1
	elif c0 > c1:
		ans = c1 * (one + zero) + zero * h
	else:
		ans = c0 * (one + zero) + one * h
	print(ans)


for _ in range(int(input())):
	(n, c0, c1, h) = map(int, input().split())
	ans = 0
	l = input()
	for elem in l:
		if elem == '1':
			if c1 > h + c0:
				ans += h + c0
			else:
				ans += c1
		elif c0 > h + c1:
			ans += h + c1
		else:
			ans += c0
	print(ans)


t = int(input())
for j in range(t):
	(n, c0, c1, h) = map(int, input().split(' '))
	list1 = list(map(int, input()))
	z = list1.count(0)
	o = list1.count(1)
	ans1 = z * c0 + o * c1
	ans2 = (z + o) * c1 + z * h
	ans3 = (z + o) * c0 + o * h
	print(min(ans1, min(ans2, ans3)))