You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $[0, n]$ on $OX$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $(x, x + 1)$ with integer $x$. So we can represent the road as a binary string consisting of $n$ characters, where character 0 means that current interval doesn't contain a crossroad, and 1 means that there is a crossroad.

Usually, we can install the pipeline along the road on height of $1$ unit with supporting pillars in each integer point (so, if we are responsible for $[0, n]$ road, we must install $n + 1$ pillars). But on crossroads we should lift the pipeline up to the height $2$, so the pipeline won't obstruct the way for cars.

We can do so inserting several zig-zag-like lines. Each zig-zag can be represented as a segment $[x, x + 1]$ with integer $x$ consisting of three parts: $0.5$ units of horizontal pipe + $1$ unit of vertical pipe + $0.5$ of horizontal. Note that if pipeline is currently on height $2$, the pillars that support it should also have length equal to $2$ units.

 [Image] 

Each unit of gas pipeline costs us $a$ bourles, and each unit of pillar — $b$ bourles. So, it's not always optimal to make the whole pipeline on the height $2$. Find the shape of the pipeline with minimum possible cost and calculate that cost.

Note that you must start and finish the pipeline on height $1$ and, also, it's guaranteed that the first and last characters of the input string are equal to 0.


-----Input-----

The fist line contains one integer $T$ ($1 \le T \le 100$) — the number of queries. Next $2 \cdot T$ lines contain independent queries — one query per two lines.

The first line contains three integers $n$, $a$, $b$ ($2 \le n \le 2 \cdot 10^5$, $1 \le a \le 10^8$, $1 \le b \le 10^8$) — the length of the road, the cost of one unit of the pipeline and the cost of one unit of the pillar, respectively.

The second line contains binary string $s$ ($|s| = n$, $s_i \in \{0, 1\}$, $s_1 = s_n = 0$) — the description of the road.

It's guaranteed that the total length of all strings $s$ doesn't exceed $2 \cdot 10^5$.


-----Output-----

Print $T$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.


-----Example-----
Input
4
8 2 5
00110010
8 1 1
00110010
9 100000000 100000000
010101010
2 5 1
00

Output
94
25
2900000000
13



-----Note-----

The optimal pipeline for the first query is shown at the picture above.

The optimal pipeline for the second query is pictured below:

 [Image] 

The optimal (and the only possible) pipeline for the third query is shown below:

 [Image] 

The optimal pipeline for the fourth query is shown below:

 [Image]

Difficulty: MEDIUM
Tags: Dynamic programming

Greedy algorithms
Skill types: Dynamic programming

Greedy algorithms

Starter code:

Solutions:
from sys import stdin
item = lambda : stdin.readline().split()
it = lambda : stdin.readline()[:-1]
for _ in range(int(stdin.readline())):
	(n, a, b) = map(int, item())
	s = it()
	x = s.find('1')
	if x == -1:
		print(n * (a + b) + b)
		continue
	res = (n + 1) * (a + b) + b
	for y in range(x + 1, n):
		if s[y] == '1':
			if y - x - 1 > 1:
				if 2 * a > (y - x - 2) * b:
					res += (y - x - 2) * b
				else:
					res += 2 * a
			res += b
			x = y
		if s[y] == '0' and s[y - 1] == '1':
			res += b
	res += a
	print(res)


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	l = list(input())
	dp1 = [10 ** 18] * (n + 1)
	dp2 = [10 ** 18] * (n + 1)
	dp1[0] = b
	i = 1
	while i < n:
		if l[i] == '0':
			if l[i - 1] != '1':
				dp1[i] = min(dp2[i - 1] + 2 * a, dp1[i - 1] + a) + b
				dp2[i] = min(dp1[i - 1] + 2 * a, dp2[i - 1] + a) + 2 * b
			else:
				dp2[i] = min(dp1[i - 1] + 2 * a, dp2[i - 1] + a) + 2 * b
			i += 1
		elif l[i] == '1':
			dp2[i] = min(dp1[i - 1] + 2 * a, dp2[i - 1] + a) + 2 * b
			i += 1
	print(min(dp1[n - 1] + a, dp2[n - 1] + 2 * a) + b)


T = int(input())
for i in range(0, T):
	ln = [int(j) for j in input().split(' ')]
	n = ln[0]
	a = ln[1]
	b = ln[2]
	st = list(input())
	ct = 0
	zct = 0
	pls = 0
	pip = 0
	seg = []
	ft = False
	for j in range(0, len(st)):
		if st[j] == '1':
			ft = False
			if ct == 0:
				seg.append(j - 1)
			ct += 1
			zct = 0
		elif zct == 0 and ct:
			ct += 1
			ft = True
			zct += 1
		else:
			if ft:
				ft = False
				ct -= 1
			zct += 1
			if zct == 2 and ct:
				seg.append(j - 1)
				pls += ct + 1
				zct = 0
				ct = 0
	if zct == 1 and ct:
		seg.append(j)
		if ft:
			ct -= 1
		pls += ct + 1
	cost = pls * (b * 2) + (n + 1 - pls) * b
	cost += (n + len(seg)) * a
	if len(seg) > 2:
		for j in range(1, len(seg) - 1, 2):
			plc = (seg[j + 1] - seg[j]) * b
			pipc = 2 * a
			if plc < pipc:
				cost -= pipc - plc
	print(cost)


inf = 10000000000000000000000000000000000000000000000000000000000000000

def solve(n, a, b, s):
	dp = [[]] * 2
	for i in range(2):
		dp[i] = [0] * n
	dp[0][0] = (n + 1) * (a + b) - a
	dp[1][0] = inf
	for i in range(1, n):
		if s[i] == '1':
			dp[1][i] = min(dp[1][i - 1] + b, dp[0][i - 1] + a + 2 * b)
			dp[0][i] = inf
		else:
			dp[0][i] = min(dp[0][i - 1], dp[1][i - 1] + a)
			dp[1][i] = min(dp[1][i - 1] + b, dp[0][i - 1] + a + 2 * b)
	return dp[0][n - 1]
for i in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	print(solve(n, a, b, s))


import sys
input = sys.stdin.readline
T = int(input())
for testcases in range(T):
	(n, a, b) = list(map(int, input().split()))
	S = list(map(int, list(input().strip())))
	S.append(0)
	ANS = (n + 1) * b + n * a
	DP = [[1 << 50, 1 << 50] for i in range(n + 1)]
	DP[0][0] = 0
	for i in range(1, n + 1):
		if S[i - 1] == S[i] == 0:
			DP[i][0] = min(DP[i - 1][0], DP[i - 1][1] + a)
			DP[i][1] = min(DP[i - 1][0] + a + b, DP[i - 1][1] + b)
		else:
			DP[i][1] = min(DP[i - 1][0] + a + b, DP[i - 1][1] + b)
	print(ANS + DP[-1][0])


t = int(input())
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	arr = [[10 ** 31 for i in range(2)] for j in range(n + 1)]
	arr[0][0] = b
	for i in range(1, n + 1):
		if s[i - 1] == '0':
			arr[i][1] = min(arr[i - 1][1] + 2 * b + a, arr[i - 1][0] + 2 * b + 2 * a)
			arr[i][0] = min(arr[i - 1][1] + 2 * a + b, arr[i - 1][0] + a + b)
		else:
			arr[i][1] = arr[i - 1][1] + 2 * b + a
	print(arr[n][0])


T = int(input())
for _ in range(T):
	(n, a, b) = [int(i) for i in input().split()]
	road = input()
	num_one = 0
	zero_seg = [0 for i in range(n)]
	num_zer = 0
	len_zer = 0
	acc_down = True
	for i in range(n):
		if road[i] == '1':
			num_one += 1
			if acc_down:
				acc_down = False
				zero_seg[num_zer] = len_zer
				len_zer = 0
				num_zer += 1
		else:
			len_zer += 1
			acc_down = True
	zero_seg[num_zer] = len_zer
	num_zer += 1
	pillars = num_one + num_zer - 1
	if num_one >= 1:
		zikzak = 2
		for i in range(1, num_zer - 1):
			if (zero_seg[i] - 1) * b > 2 * a:
				zikzak += 2
			else:
				pillars += zero_seg[i] - 1
		res = (n + 1) * b + n * a
		res += zikzak * a
		res += pillars * b
		print(res)
	else:
		print((n + 1) * b + n * a)


n = int(input())
for i in range(n):
	q = 0
	w = 0
	su = 0
	(d, c, st) = [int(i) for i in input().split()]
	s = input()
	k = 0
	flag = 1
	for i in range(len(s)):
		if s[i] == '0':
			k += 1
		elif flag == 1:
			su += 2 * st + c
			flag = 2
			k = 0
		else:
			if k < 2:
				su += (k + 1) * st
			else:
				su += min((k - 1) * st, 2 * c) + 2 * st
			k = 0
	if flag == 2:
		su += c
	su += st * (d + 1) + d * c
	print(su)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, a, b) = map(int, input().split())
	s = input()
	dp = [[0] * 2 for _ in range(n + 1)]
	for i in range(n):
		if s[i] == '1':
			dp[i + 1][0] = 10 ** 18
		else:
			dp[i + 1][0] = min(dp[i][0] + a + b, dp[i][1] + 2 * a + 2 * b)
		if i == 0:
			dp[i + 1][1] = dp[i][0] + 2 * a + b
		elif s[i] == '1':
			dp[i + 1][1] = dp[i][1] + a + 2 * b
		else:
			dp[i + 1][1] = min(dp[i][0] + 2 * a + b, dp[i][1] + a + 2 * b)
	print(dp[n][0] + b)


Q = int(input())
Qs = []
for _ in range(Q):
	(n, a, b) = map(int, input().split())
	s = input()
	Qs.append([n, a, b, s])
for (n, a, b, S) in Qs:
	l = 0
	L = []
	for s in list(S):
		if s == '0':
			l += 1
		else:
			if not L:
				L.append(l)
			elif l >= 2:
				L.append(l)
			l = 0
	L.append(l)
	if len(L) == 1:
		ans = a * n + b * (n + 1)
	else:
		ans = a * (n + 2) + b * (2 * (n + 1) - L[0] - L[-1])
		maxl = len(L)
		for (i, l) in enumerate(L):
			if i == 0 or i == maxl - 1:
				continue
			if (l - 1) * b > 2 * a:
				ans = ans + 2 * a - (l - 1) * b
	print(ans)


t = int(input())
while t != 0:
	t -= 1
	(n, a, b) = map(int, input().split())
	s = input()
	dp = [[10 ** 20 for _ in range(n + 1)] for _ in range(2)]
	dp[0][0] = b
	for i in range(n):
		if s[i] == '0':
			dp[0][i + 1] = min(dp[0][i] + a + b, dp[1][i] + 2 * a + b)
			dp[1][i + 1] = min(dp[1][i] + a + 2 * b, dp[0][i] + 2 * (a + b))
		else:
			dp[1][i + 1] = dp[1][i] + a + 2 * b
	print(dp[0][n])


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	ans = 0
	if '1' not in s:
		print(n * (b + a) + b)
		continue
	i = 0
	while s[i] == '0':
		i += 1
		ans += a + b
	ans += a
	j = n - 1
	while s[j] == '0':
		j -= 1
		ans += a + b
	ans += a
	temp = s[i:j + 1]
	i = 0
	m = len(temp)
	while i < m:
		if temp[i] == '1':
			ans += 2 * b + a
			i += 1
		else:
			ans += 2 * b
			start = i
			while i < m and temp[i] == '0':
				i += 1
			ans += min((i - start - 1) * b + (4 + i - start - 2) * a, 2 * b * (i - start - 1) + (i - start) * a)
	print(ans + 2 * b)


t = int(input())
for j in range(t):
	(n, a, b) = map(int, input().split())
	s = str(input())
	string = [s[i] for i in range(n)]
	for i in range(1, n - 1):
		if string[i] == '0':
			if string[i - 1] == '1' and string[i + 1] == '1':
				string[i] = '1'
	del s
	zero = []
	one = []
	positions_of_one = []
	ones = 0
	(k_zero, k_one) = (0, 0)
	for i in range(n):
		if string[i] == '0' or i == n - 1:
			k_zero += 1
			one.append(k_one)
			k_one = 0
		if string[i] == '1' or i == n - 1:
			k_one += 1
			zero.append(k_zero)
			k_zero = 0
			if string[i] == '1':
				ones += 1
				positions_of_one.append(i)
	if ones == 0:
		print(int(b * (n + 1) + a * n))
		continue
	zero.pop(len(zero) - 1)
	zero.pop(0)
	s = (positions_of_one[0] + (n - positions_of_one[len(positions_of_one) - 1] - 1)) * b + (positions_of_one[0] + (n - positions_of_one[len(positions_of_one) - 1] + 1)) * a
	for i in range(len(one)):
		if one[i] != 0:
			s += (one[i] + 1) * 2 * b + a * one[i]
	for i in range(len(zero)):
		if zero[i] != 0:
			s += min(a * zero[i] + (zero[i] - 1) * 2 * b, (zero[i] + 2) * a + (zero[i] - 1) * b)
	print(s)


m = int(input())
for i in range(m):
	t = 0
	(n, a, b) = map(int, input().split())
	s = list(input())
	for j in range(n):
		s[j] = int(s[j])
	k = s[0]
	p = 1
	d = []
	for j in range(1, n):
		if s[j] == s[j - 1]:
			p += 1
		else:
			d.append(p)
			p = 1
	d.append(p)
	for j in range(len(d)):
		if k == 0:
			if j == 0:
				t += a + d[j] * a + 1 * b * d[j]
			elif j == len(d) - 1:
				t += a + d[j] * a + 1 * b * d[j] + 2 * b
			elif 2 * a + d[j] * a + 1 * b * (d[j] - 1) + 2 * b <= 2 * b * d[j] + d[j] * a:
				t += 2 * a + d[j] * a + 1 * b * (d[j] - 1) + 2 * b
			else:
				t += 2 * b * d[j] + d[j] * a
			k = 1
		else:
			t += 2 * b * d[j] + d[j] * a
			k = 0
			if j == len(d) - 1:
				t += 2 * b
	if len(d) == 1 and s[0] == 0:
		t = d[0] * a + (d[0] + 1) * b
	elif len(d) == 1 and s[0] == 1:
		t = d[0] * a + (d[0] + 1) * 2 * b
	print(t)


t = int(input())
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	arr = []
	c = '0'
	k = 0
	for i in range(n):
		if s[i] == c:
			k += 1
		else:
			arr.append(k)
			k = 1
			c = s[i]
	if len(arr) == 0:
		print(n * a + b * n + b)
	else:
		ans = k * (a + b) + (a + b) * arr[0] + a
		for i in range(1, len(arr)):
			if i % 2 == 1:
				ans += (arr[i] + 1) * (2 * b + a)
			else:
				ans += min((arr[i] + 1) * a + b * (arr[i] - 1), 2 * b * (arr[i] - 1) + a * (arr[i] - 1))
		print(ans)


T = int(input())
for t in range(T):
	(n, a, b) = map(int, input().split())
	A = list(map(int, list('0' + input() + '0')))
	DP = [[10 ** 18 for i in range(2)] for j in range(n + 1)]
	DP[0][0] = b
	for i in range(1, n + 1):
		if A[i + 1] == 0 and A[i] == 0:
			DP[i][0] = min(DP[i - 1][0] + a + b, DP[i - 1][1] + 2 * a + b)
		DP[i][1] = min(DP[i - 1][0] + 2 * a + 2 * b, DP[i - 1][1] + a + 2 * b)
	print(DP[n][0])


T = int(input())
for tt in range(0, T):
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	cntZero = 1
	zeros = []
	ones = []
	cntOne = 0
	cost = 0
	for i in range(1, n):
		if s[i] == '0':
			cntZero += 1
			if cntOne > 0:
				ones.append(cntOne)
				cntOne = 0
		elif s[i] == '1':
			cntOne += 1
			if cntZero > 0:
				zeros.append(cntZero)
				cntZero = 0
	zeros.append(cntZero)
	if len(ones) == 0:
		cost = zeros[0] * a + (zeros[0] + 1) * b
		print(cost)
		continue
	for k in ones:
		cost += k * (a + 2 * b) + 2 * b
	for i in range(1, len(zeros) - 1):
		val1 = zeros[i] * a + (zeros[i] - 1) * 2 * b
		val2 = 2 * a + (zeros[i] - 2) * a + 2 * a + (zeros[i] - 1) * b
		if zeros[i] == 1:
			cost += val1
		else:
			cost += min((val1, val2))
	cost += (zeros[0] - 1) * a + 2 * a + zeros[0] * b
	cost += (zeros[-1] - 1) * a + 2 * a + zeros[-1] * b
	print(cost)


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

def main():
	for t in range(int(input())):
		(n, a, b) = map(int, input().split())
		d = input().rstrip()
		if len(d) >= 2:
			c = math.inf
			dp = [[c, c] for j in range(n)]
			dp[0][0] = 2 * b + a if d[1] == '0' else 3 * b + 2 * a
			for i in range(1, n - 1):
				if d[i] == '0' and d[i + 1] == '1' and (d[i - 1] == '1'):
					dp[i][1] = dp[i - 1][1] + 2 * b + a
				elif d[i] == '0' and d[i + 1] == '1' and (d[i - 1] == '0'):
					dp[i][0] = dp[i - 1][0] + 2 * a + 2 * b
					dp[i][1] = dp[i - 1][1] + a + 2 * b
				elif d[i] == '0' and d[i + 1] == '0' and (d[i - 1] == '1'):
					dp[i][0] = dp[i - 1][1] + 2 * a + b
					dp[i][1] = dp[i - 1][1] + a + 2 * b
				elif d[i] == '0' and d[i + 1] == '0' and (d[i - 1] == '0'):
					dp[i][0] = min(dp[i - 1][0] + a + b, dp[i - 1][1] + 2 * a + b)
					dp[i][1] = min(dp[i - 1][1] + 2 * b + a, dp[i - 1][0] + 2 * a + 3 * b)
				elif d[i] == '1' and d[i - 1] == '0':
					dp[i][1] = min(dp[i - 1][1] + a + 2 * b, dp[i - 1][0] + a + 2 * b)
				else:
					dp[i][1] = dp[i - 1][1] + a + 2 * b
			if d[-2] == '0':
				print(min(dp[-2][1] + 2 * a + b, dp[-2][0] + a + b))
			else:
				print(dp[-2][1] + 2 * a + b)
		else:
			print(a + 2 * b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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


for _ in range(int(input())):
	(n, a, b) = list(map(int, input().split()))
	s = [int(i) for i in input()]
	(temp, ar, tot) = [0] * 3
	tot += a * n
	for i in s:
		if not i:
			if ar:
				temp += 1
			ar = 0
		else:
			temp += 1
			ar = 1
	tot += temp * b if temp else 0
	if sum(s):
		tot += a
	curr = i = 0
	while i < len(s):
		if s[i]:
			curr = 1
		elif curr:
			temp = i
			while temp < len(s) and (not s[temp]):
				temp += 1
			if temp == len(s):
				tot += a if sum(s) else 0
			elif (temp - i - 1) * b <= 2 * a:
				tot += (temp - i - 1) * b
			elif 2 * a < (temp - i - 1) * b:
				tot += 2 * a
			i = temp
		i += 1
	print(tot + (n + 1) * b)


T = int(input())
for _ in range(T):
	(n, a, b) = list(map(int, input().split()))
	s = input()
	ans = n * a + (n + 1) * b
	li = s.find('1')
	if li >= 0:
		ri = s.rfind('1')
		ans += a + a + (ri - li + 2) * b
		lens = []
		for i in range(li + 1, ri):
			if s[i] == '0':
				if s[i - 1] == '1':
					lens.append(0)
				lens[-1] += 1
		for l in lens:
			sm = a + a - (l - 1) * b
			if l > 1 and sm < 0:
				ans += sm
	print(ans)


q = int(input())
for _ in range(q):
	(n, a, b) = map(int, input().split())
	s = input()
	f = 0
	cost = b
	cost2 = 0
	for i in range(n):
		if s[i] == '0':
			if f:
				cost2 += a + 2 * b
			cost += a + b
			if i + 1 < n:
				if s[i + 1] == '1':
					cost += a + b
		else:
			if cost2:
				cost = min(cost, cost2)
				cost2 = 0
			cost += a + 2 * b
			if i + 1 < n:
				if s[i + 1] == '0':
					cost2 = cost
					if i == 0:
						cost2 += b
					cost += a
					f = 1
	if cost2:
		if i == n - 1:
			cost2 = cost2 + a - b
		cost = min(cost, cost2)
	print(cost)


t = int(input())
for x in range(t):
	(n, a, b) = map(int, input().split())
	l = list(input())
	s = 0
	i = 0
	while i < n:
		if i == 0:
			while i < n and l[i] != '1':
				i += 1
				s += a + b
			s += a
			if i == n:
				s -= a
				break
		if l[i] == '0':
			c = 0
			while i < n and l[i] != '1':
				c += 1
				i += 1
			if i == n:
				s += (c + 1) * b + (c + 1) * a
				break
			elif c > 1:
				s1 = min((c + 1) * b + (c + 2) * a, c * 2 * b + c * a)
				s += s1
			else:
				s += 2 * b + a
		if l[i] == '1':
			while l[i] != '0':
				s += 2 * b + a
				i += 1
			if i == n - 1:
				s += 2 * b + 2 * a
				break
	print(s + b)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, pip_cost, pillor_cost) = map(int, sys.stdin.readline().split())
	strr = sys.stdin.readline()
	arr = [i + 1 for i in range(n) if strr[i] == '1']
	pip_len = n + 2 if arr else n
	pillor_len = (n + 1) * 2 - (arr[0] - 1) - (n - arr[-1]) if arr else n + 1
	for i in range(1, len(arr)):
		length = arr[i] - 2 - arr[i - 1]
		if length > 0:
			if 2 * pip_cost < length * pillor_cost:
				pip_len += 2
				pillor_len -= length
	print(pip_len * pip_cost + pillor_len * pillor_cost)


from sys import setcheckinterval, stdin
setcheckinterval(1000)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))
for _ in range(iin()):
	(nn, p, h) = lin()
	s = list(input())
	sa = []
	i = 0
	while i < nn:
		ch = 0
		val = s[i]
		while i < nn and s[i] == val:
			i += 1
			ch += 1
		sa.append([val, ch])
	l = len(sa)
	ans = h
	for i in range(l):
		n = sa[i][1]
		if sa[i][0] == '0':
			if i == 0:
				if l - 1 == 0:
					ans += n * (p + h)
				else:
					ans += (n + 1) * (p + h)
			elif i == l - 1:
				ans += p * (n + 1) + n * h
			elif n == 1:
				ans += p + 2 * h
			else:
				ans += min((n + 2) * p + (n + 1) * h, n * (p + 2 * h))
		else:
			ans += n * (p + 2 * h)
	print(ans)


def gns():
	return list(map(int, input().split()))
t = int(input())
for ti in range(t):
	(n, a, b) = gns()
	s = input()
	ans = s.split('1')
	ans = [len(x) for x in ans if len(x) > 0]
	cst = a * n + 2 * a
	cst += (n + 1) * 2 * b - ans[0] * b - ans[-1] * b
	if len(ans) == 1:
		print((n + 1) * b + n * a)
		continue
	for i in range(1, len(ans) - 1):
		x = ans[i]
		cst = min(cst, cst - (x - 1) * b + a * 2)
	print(cst)


def minCost(n, road, a, b):
	start = end = price = 0
	price += b
	while end != n:
		if end < n - 1 and road[end + 1] == 0:
			end += 1
		else:
			length = end - start
			if start == 0:
				if end == n - 1:
					return n * a + n * b + b
				else:
					price += (a + b) * (length + 2)
			elif end == n - 1:
				price += (a + b) * (length + 2)
			elif length:
				if b * (length - 1) < 2 * a:
					price += (a + 2 * b) * (length + 1)
				else:
					price += (a + b) * (length + 3)
			else:
				price += a + 2 * b
			start = end = end + 1
	return price
r = int(input(''))
for i in range(0, r):
	(road_size, t_price, s_price) = [int(x) for x in str(input('')).split(' ')]
	road = [int(x) for x in str(input(''))]
	print(minCost(road_size, road, t_price, s_price))


from sys import stdin, stdout
from collections import defaultdict
import math
import copy
T = int(input())
for i in range(T):
	(N, A, B) = [int(x) for x in stdin.readline().split()]
	s = input()
	one_idx = []
	for j in range(N):
		if s[j] == '1':
			one_idx.append(j)
	if len(one_idx) == 0:
		print(A * N + B * (N + 1))
		continue
	ans = 0
	L = one_idx[0]
	pipe = L - 1 + 2 + 1
	pillar = L + 2 + 2
	ans += A * pipe + B * pillar
	for k in range(1, len(one_idx)):
		L = one_idx[k] - one_idx[k - 1] - 1
		if L <= 1:
			pipe = L * 1 + 1
			pillar = L * 2 + 2
			ans += A * pipe + B * pillar
		else:
			pipe = 2 * 2 + (L - 2) + 1
			pillar = L - 1 + 2 + 2
			cost1 = A * pipe + B * pillar
			pipe = L + 1
			pillar = 2 * L + 2
			cost2 = A * pipe + B * pillar
			m = min(cost1, cost2)
			ans += m
	L = N - 1 - one_idx[-1]
	pipe = 2 + (L - 1)
	pillar = L
	cost1 = A * pipe + B * pillar
	pipe = L - 1 + 2
	pillar = 2 * (L - 1) + 1
	cost2 = A * pipe + B * pillar
	m = min(cost1, cost2)
	ans += m
	print(ans)


def next_one(s, current):
	for i in range(current + 1, len(s)):
		if int(s[i]) == 1:
			return i
	return -1
t = int(input())
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	changed_dig = False
	price = n * a
	for j in range(n - 1):
		if not changed_dig:
			current = s[j]
		if int(current) == 0 and int(s[j + 1]) == 0:
			price += b
			current = -1
		elif int(current) == 0 and int(s[j + 1]) == 1:
			price += 2 * b + a
			current = -1
		elif int(current) == 1 and int(s[j + 1]) == 0:
			if next_one(s, j) == -1:
				price += 2 * b + a
				current = -1
			else:
				diff = next_one(s, j) - j - 2
				if diff * b < 2 * a:
					price += 2 * b
					current = 1
				else:
					price += 2 * b + a
					current = -1
		elif int(current) == 1 and int(s[j + 1]) == 1:
			price += 2 * b
			current = -1
		changed_dig = False
		if current == 1:
			changed_dig = True
	print(price + 2 * b)


T = int(input())
for _ in range(T):
	(n, a, b) = map(int, input().split())
	s = input()
	res = 0
	i = 0
	while i < n and s[i] == '0':
		res += a + b
		i += 1
	if i < n:
		res += 2 * a
		while s[n - 1] == '0':
			res += a + b
			n -= 1
		res += (n - i + 1) * 2 * b + (n - i) * a
		nz = 0
		while i < n:
			if s[i] == '1':
				if nz > 1 and 2 * a - (nz - 1) * b < 0:
					res += 2 * a - (nz - 1) * b
				nz = 0
			else:
				nz += 1
			i += 1
	else:
		res += b
	print(res)


T = int(input())
for i in range(T):
	(n, a, b) = map(int, input().split())
	s = input()
	dp = [[1000000000000000001 for i in range(2)] for j in range(n + 1)]
	dp[0][0] = a + 2 * b
	dp[0][1] = 2 * a + 3 * b
	for i in range(n - 1):
		if s[i] == '0':
			if s[i + 1] == '1':
				dp[i + 1][1] = dp[i][1] + a + 2 * b
			else:
				dp[i + 1][1] = min(dp[i][1] + a + 2 * b, dp[i][0] + 2 * a + 2 * b)
				dp[i + 1][0] = min(dp[i][1] + 2 * a + b, dp[i][0] + a + b)
		elif s[i + 1] == '1':
			dp[i + 1][1] = dp[i][1] + a + 2 * b
		else:
			dp[i + 1][1] = dp[i][1] + a + 2 * b
			dp[i + 1][0] = dp[i][1] + 2 * a + b
	print(dp[n - 1][0])


t = int(input())
while t:
	(n, a, b) = [int(x) for x in input().split()]
	road = input()
	what = True
	j = 0
	answer = 0
	first = 0
	while j < n and road[j] != '1':
		j += 1
	first = j
	for i in range(j + 1, n):
		if road[i] == '0' and what:
			x = i - j
			answer += (x + 1) * 2 * b + x * a
			j = i
			what = False
		elif not what and road[i] == '1':
			x = i - j
			answer += min(a * x + (x - 1) * b * 2, (x + 2) * a + (x - 1) * b)
			j = i
			what = True
	begin = 0
	for i in road:
		if i == '1':
			break
		begin += 1
	alpha = a + begin * a + begin * b
	end = 0
	for i in reversed(road):
		if i == '1':
			break
		end += 1
	if road.count('1') != 0:
		beta = a + end * a + end * b
	else:
		alpha -= a
		beta = b
	print(answer + alpha + beta)
	t -= 1


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().rstrip().split())
	s = input() + '0'
	(m1, m2) = (b, float('inf'))
	for i in range(n):
		m3 = min(m1 + 2 * a + 2 * b, m2 + a + b * 2)
		if s[i + 1] == '0' and s[i] == '0':
			m1 = min(m1 + a + b, m2 + 2 * a + b)
		else:
			m1 = float('inf')
		m2 = m3
	print(m1)


for _ in range(int(input())):
	(N, pipe, pillar) = map(int, input().split())
	S = input()
	Bins = []
	flag = True
	for i in range(len(S)):
		if S[i] == '0' and flag:
			flag = False
			O = i
		elif S[i] == '1' and (not flag):
			flag = True
			Bins.append((O, i - 1))
	if S[-1] == '0':
		Bins.append((O, len(S) - 1))
	Cost = 2 * N * pillar + (N + 2) * pipe
	if S.count('0') == N:
		print((N + 1) * pillar + N * pipe)
		continue
	if Bins[0][1] == 0:
		pass
	else:
		Cost -= Bins[0][1] * pillar
	for i in range(1, len(Bins) - 1):
		X = Bins[i][1] - Bins[i][0]
		if X == 0:
			continue
		elif 2 * pipe - X * pillar < 0:
			Cost += 2 * pipe - X * pillar
	if Bins[-1][0] == Bins[-1][1]:
		pass
	else:
		Cost -= (Bins[-1][1] - Bins[-1][0]) * pillar
	print(Cost)


t = int(input())
for _ in range(t):
	(n, a, b) = list(map(int, input().split()))
	s = input()
	a1 = 0
	start = 1
	total = 0
	if '1' in s:
		for i in range(1, n - 1):
			if s[i] == '0':
				start += 1
			else:
				break
		total += (start + 1) * a + start * b + 2 * b
		end = n - 2
		for i in range(n - 2, start, -1):
			if s[i] == '0':
				end = end - 1
			else:
				break
		total += (n - 1 - end + 1) * a + (n - 1 - end) * b
		j = start
		c = 0
		while j <= end:
			if s[j] == '1':
				total += a + 2 * b
				j += 1
			else:
				while s[j] == '0':
					j += 1
					c += 1
				if c == 1:
					total += a + 2 * b
				else:
					total += min(a * (c + 2) + (c - 1) * b, a * c + (c - 1) * 2 * b) + 2 * b
				c = 0
		print(total)
	else:
		print(n * a + (n + 1) * b)


import sys
input = sys.stdin.readline

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

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

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

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	(n, a, b) = getVars()
	s = getStr()
	p = s.find('1')
	res = n * a + (n + 1) * b
	if p > -1:
		res += 2 * a
	while p > 0:
		p0 = s.find('0', p)
		res += (p0 - p + 1) * b
		p = s.find('1', p0)
		if p > -1:
			res += min((p - p0 - 1) * b, 2 * a)
	print(res)


import sys
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
for _ in range(ri(1)):
	(n, pipe_cost, pilar_cost) = ri()
	take = input()
	dp = [[999999999999999999999999999999999999999, 999999999999999999999999999999999999999] for i in range(n + 1)]
	cost = 0
	temp = 0
	pilars = [1 for i in range(n + 1)]
	for i in range(n):
		if take[i] == '1':
			pilars[i] = 2
			pilars[i + 1] = 2
	dp[0][0] = pilar_cost
	dp[0][1] = 9999999999999999999999999999999999999999999999
	for i in range(1, n + 1):
		if pilars[i] == 1:
			dp[i][1] = 2 * pilar_cost + min(dp[i - 1][0] + 2 * pipe_cost, dp[i - 1][1] + pipe_cost)
			dp[i][0] = pilar_cost + min(dp[i - 1][1] + 2 * pipe_cost, dp[i - 1][0] + pipe_cost)
		else:
			dp[i][1] = 2 * pilar_cost + min(dp[i - 1][0] + 2 * pipe_cost, dp[i - 1][1] + pipe_cost)
	print(dp[n][0])


MAXN = float('inf')
T = int(input())
for _ in range(T):
	(n, a, b) = map(int, input().split())
	s = list(map(int, input()))
	dp = [b, MAXN]
	for i in range(n):
		if s[i]:
			(dp[0], dp[1]) = (MAXN, dp[1] + a + 2 * b)
		else:
			(dp[0], dp[1]) = (min(dp[0] + a + b, dp[1] + 2 * a + b), min(dp[0] + 2 * a + 2 * b, dp[1] + a + 2 * b))
	print(dp[0])


mod = int(1000000000.0) + 7
x = float('inf')

def ip(mode):
	if mode == 0:
		return int(input())
	if mode == 1:
		return list(map(int, input().split()))
	if mode == 2:
		return input()
	if mode == 3:
		return list(map(str, input().split()))
	if mode == 4:
		return map(int, input().split())
	if mode == 5:
		return map(str, input().split())
for _ in range(int(input())):
	(n, a, b) = ip(4)
	dp = [[0, 0, 0] for i in range(n + 1)]
	s = ip(2)
	dp[0][1] = b
	dp[0][2] = x
	for i in range(1, n):
		dp[i][2] = min(dp[i - 1][1] + 2 * a + 2 * b, dp[i - 1][2] + a + 2 * b)
		if s[i] == '0' and s[i - 1] == '0':
			dp[i][1] = min(dp[i - 1][1] + a + b, dp[i - 1][2] + b + 2 * a)
		else:
			dp[i][1] = x
	dp[n][1] = min(dp[n - 1][1] + a + b, dp[n - 1][2] + b + 2 * a)
	print(dp[n][1])


import math
n = int(input())
out = ''
for order in range(n):
	(n, a, b) = list(map(int, input().split()))
	query = input()
	maxZeros2StayUp = math.floor(2 * a / b + 1)
	for zeroNum in range(1, maxZeros2StayUp + 1):
		str2search = '1' + '0' * zeroNum + '1'
		str2replace = '1' * (zeroNum + 2)
		query = query.replace(str2search, str2replace)
		query = query.replace(str2search, str2replace)
	stepCount = 0
	for index in range(len(query) - 1):
		if query[index] != query[index + 1]:
			stepCount = stepCount + 1
	oneCount = query.count('1')
	price = (n + stepCount) * a + (n + 1) * b + (oneCount + stepCount / 2) * b
	out = out + str(int(price)) + '\n'
cleaned = out.rstrip()
print(cleaned)


t = int(input())
while t > 0:
	t -= 1
	(n, a, b) = map(int, input().split())
	s = input()
	i = 0
	ans = 0
	while i < n:
		j = i
		while j < n:
			if s[j] != s[i]:
				break
			j += 1
		if s[i] == '0':
			k = j - i
			c1 = (k + 2) * a + (k + 1) * b
			c2 = 2 * b * k + k * a
			if j == n:
				c1 -= a + b
				c2 -= b - a
			if i == 0:
				c1 -= a - b
				c2 += 2 * b
			if i == 0 or j == n:
				ans += c1
			else:
				ans += min(c1, c2)
		else:
			ans += (j - i) * a + 2 * (j - i) * b
		i = j
	print(ans)


import sys
maxx = 100000000000000001
q = int(input())
for i in range(q):
	ch = input()
	L = [int(i) for i in ch.split()]
	n = L[0]
	a = L[1]
	b = L[2]
	ch = input()
	M = [[b, maxx]] + [[maxx, maxx] for i in range(n)]
	for j in range(1, n + 1):
		M[j][1] = min(M[j - 1][0] + 2 * b + 2 * a, M[j - 1][1] + 2 * b + a)
		if (j - 1 < 0 or ch[j - 1] == '0') and (j >= n or ch[j] == '0'):
			M[j][0] = min(M[j - 1][0] + a + b, M[j - 1][1] + 2 * a + b)
	print(M[-1][0])


q = int(input())
R = lambda : list(map(int, input().split()))
for j in range(q):
	(n, a, b) = R()
	l = input()
	l += '0'
	n += 1
	s = b
	t = 0
	if a >= b:
		p = 1
	else:
		p = 0
	k = 1
	test = 0
	for i in range(0, n - 1):
		if l[i] == '0' and l[i + 1] == '1' and (t == 0):
			s += 2 * b + 2 * a
		elif l[i] == '0' and l[i + 1] == '1' and (t == 1):
			if (k - 1) * b - 2 * a <= 0:
				s += k * a + 2 * k * b
			else:
				s += (k + 2) * a + (k + 1) * b
			k = 1
		elif l[i] == '1' and l[i + 1] == '1':
			s += 2 * b + a
		elif l[i] == '1' and l[i + 1] == '0':
			s += a + 2 * b
			t = 1
		elif l[i] == '0' and l[i + 1] == '0' and (t == 1):
			k += 1
			test = 1
		elif l[i] == '0' and l[i + 1] == '0' and (t == 0):
			s += a + b
	k -= 1
	if k > 0 and test == 1:
		s += (k + 1) * a + k * b
	print(s)


for k in range(int(input())):
	(n, cpipe, cpillar) = map(int, input().split())
	s = input()
	if int(s) == 0:
		print(n * cpipe + n * cpillar + cpillar)
	else:
		ti = 0
		for i in range(n):
			if s[i] == '1':
				ti = i
				break
		l = []
		ans = 0
		for i in range(ti + 1, n):
			if s[i] == '1':
				l.append(i - ti)
				ti = i
		for i in range(len(l)):
			if l[i] <= 2:
				ans += l[i] * cpillar
			else:
				ans += 2 * cpillar + min(2 * cpipe, (l[i] - 2) * cpillar)
		print(n * cpipe + (n + 1) * cpillar + ans + 2 * cpillar + 2 * cpipe)


q = int(input())
for _ in range(q):
	(n, a, b) = map(int, input().split())
	s = str(input())
	dp = [0] * (len(s) + 1)
	for i in range(len(s) + 1):
		dp[i] = [0] * 2
	dp[0][0] = b
	dp[0][1] = 1000000000000000.0
	for i in range(n):
		if s[i] == '0':
			dp[i + 1][0] = min(dp[i][0] + a, dp[i][1] + a + a) + b
			dp[i + 1][1] = min(dp[i][1] + a, dp[i][0] + a + a) + b + b
		else:
			dp[i + 1][0] = 1000000000000000.0
			dp[i + 1][1] = dp[i][1] + b + b + a
	print(dp[n][0])


import math
import sys
from sys import stdin, stdout
inp = lambda : int(stdin.readline())
mulinp = lambda : map(int, input().split())
for _ in range(inp()):
	(n, a, b) = mulinp()
	s = input()
	dp = [[pow(10, 18)] * 2 for i in range(n + 1)]
	dp[0][0] = b
	for i in range(n):
		if s[i] == '0':
			dp[i + 1][0] = dp[i][0] + a + b
			dp[i + 1][1] = dp[i][0] + 2 * (a + b)
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 2 * a + b)
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a + 2 * b)
		else:
			dp[i + 1][1] = dp[i][1] + a + 2 * b
	print(dp[n][0])


import sys, math, queue, collections
MOD = 10 ** 9 + 7
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = 'x' + input()
	dp0 = [10 ** 20 for i in range(n + 1)]
	dp1 = [10 ** 20 for i in range(n + 1)]
	dp0[0] = b
	for i in range(1, len(s)):
		dp1[i] = min(dp1[i - 1], dp0[i - 1] + a) + a + 2 * b
		if s[i] == '0':
			dp0[i] = min(dp0[i - 1], dp1[i - 1] + a + b) + a + b
	print(dp0[n])


import os, sys
from io import BytesIO, IOBase
from math import inf

def main():
	for _ in range(int(input())):
		(n, a, b) = map(int, input().split())
		s = input().strip()
		dp = [[inf, inf, inf, inf] for _ in range(n + 1)]
		dp[0][0] = 0
		for i in range(1, n + 1):
			if s[i - 1] == '1':
				dp[i][3] = min(dp[i - 1][3], dp[i - 1][2]) + 2 * b + a
			else:
				dp[i][3] = min(dp[i - 1][3], dp[i - 1][2]) + 2 * b + a
				dp[i][2] = min(dp[i - 1][1], dp[i - 1][0]) + 2 * b + 2 * a
				dp[i][1] = min(dp[i - 1][2], dp[i - 1][3]) + b + 2 * a
				dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + b + a
		print(min(dp[-1][0], dp[-1][1]) + b)
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()


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math
import heapq

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

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
t = intIn()
for i in range(t):
	(n, a, b) = listIn()
	s = stringIn()
	cost = b
	f = 0
	li = []
	idx = -1
	for i in range(n):
		if s[i] == '1':
			li.append(i - idx - 1)
			idx = i
	idx = 1
	l = len(li)
	i = 0
	while i < n - 1:
		if s[i] == '0':
			if not f:
				if s[i + 1] == '0':
					cost += a + b
				else:
					f = 1
					cost += 2 * a + 2 * b
			elif idx == l:
				if s[i - 1] == '1':
					cost += 2 * a + b
				else:
					cost += a + b
			i += 1
		else:
			cost += a + 2 * b
			if idx < l:
				d = li[idx]
				if d < 2:
					cost += d * (a + 2 * b)
				else:
					c1 = d * (a + 2 * b)
					c2 = 4 * a + 3 * b + max(0, d - 2) * (a + b)
					cost += min(c1, c2)
				idx += 1
				i += d + 1
			else:
				i += 1
	if s[n - 2] == '1':
		print(cost + 2 * a + b)
	else:
		print(cost + a + b)


def int_multiple():
	return [int(c) for c in input().split()]

def int_single():
	return int(input())

def str_multiple():
	return [c for c in input().split()]

def str_single():
	return input()
T = int_single()
res = []
for i in range(T):
	(n, pipe, pillar) = int_multiple()
	s = str_single()
	r = 0
	fs = -1
	ls = -1
	for j in range(n):
		if s[j] == '1':
			fs = j
			break
	for j in reversed(range(n)):
		if s[j] == '1':
			ls = j
			break
	if ls < 0:
		r = (n + 1) * pillar + n * pipe
	elif ls - fs <= 1:
		r = (n + 1) * pillar + n * pipe + 2 * pipe + (ls - fs + 2) * pillar
	else:
		r += (fs - 1) * pipe + 2 * pipe + fs * pillar
		r += (n - 2 - ls) * pipe + 2 * pipe + (n - 1 - ls) * pillar
		ones = 0
		zeros = 0
		for j in range(fs, ls + 1):
			if s[j] == '1':
				if zeros >= 2:
					opt1 = (zeros - 2) * pipe + 4 * pipe + (zeros - 1) * pillar
					opt2 = zeros * pipe + (zeros - 1) * 2 * pillar
					choosen = min(opt1, opt2) + (ones + 1) * 2 * pillar + ones * pipe
					r += choosen
					ones = 1
					zeros = 0
				else:
					ones += zeros + 1
					zeros = 0
			else:
				zeros += 1
		last_sum = ones * pipe + (ones + 1) * pillar * 2
		r += last_sum
	res.append(r)
for w in res:
	print(w)


from sys import stdin
T = int(stdin.readline())
for i in range(0, T):
	(n, a, b) = (int(j) for j in stdin.readline().split())
	s = stdin.readline()
	cost = (n + 1) * b + n * a
	zero = list()
	one = list()
	zero_count = 0
	one_count = 0
	for j in s:
		if j == '0':
			zero_count += 1
			if one_count != 0:
				one.append(one_count)
				one_count = 0
		if j == '1':
			one_count += 1
			if zero_count != 0:
				zero.append(zero_count)
				zero_count = 0
	if len(zero) == 0:
		print(cost)
	else:
		cost += 2 * a
		for j in one:
			cost += (j + 1) * b
		for j in range(1, len(zero)):
			cost += min(2 * a, (zero[j] - 1) * b)
		print(cost)


for TT in range(1, int(input()) + 1):
	(n, a, b) = map(int, input().split())
	s = input()
	dp = [0, float('inf')]
	for i in range(n):
		if '1' in s[i:i + 2]:
			dp = [float('inf'), min(dp[0] + a, dp[1]) + b]
		else:
			dp = [min(dp[0], dp[1] + a), min(dp[0] + a, dp[1]) + b]
	print(dp[0] + n * (a + b) + b)


for _ in range(int(input())):
	(n, a, b) = [int(i) for i in input().split()]
	data = input() + '0'
	inf = 1 << 50
	dp = [[0, inf]]
	for i in range(1, n + 1):
		dp.append([0, 0])
		if data[i] == '0' and data[i - 1] == '0':
			dp[-1][0] = min(dp[-2][0], dp[-2][1] + a)
			dp[-1][1] = min(dp[-2][1] + b, dp[-2][0] + a + b)
		else:
			dp[-1][0] = inf
			dp[-1][1] = min(dp[-2][1] + b, dp[-2][0] + a + b)
	print(dp[-1][0] + b + n * (a + b))


t = int(input())
import sys
input = sys.stdin.readline
maxi = 9999999999999999999999999999999999999999999999999999999
while t > 0:
	t -= 1
	(n, aa, b) = map(int, input().split())
	a = list(input())
	for i in range(n):
		a[i] = int(a[i])
	dp = [[0, 0] for i in range(n + 1)]
	if a[1] == 0:
		dp[1][0] = aa + 2 * b
		dp[1][1] = 2 * aa + 3 * b
	elif a[1] == 1:
		dp[1][0] = maxi
		dp[1][1] = 2 * aa + 3 * b
	for i in range(1, n - 1):
		if a[i + 1] == 0:
			dp[i + 1][0] = min(dp[i][0] + aa + b, dp[i][1] + 2 * aa + b)
			dp[i + 1][1] = min(dp[i][0] + 2 * aa + 2 * b, dp[i][1] + aa + 2 * b)
		else:
			dp[i + 1][0] = maxi
			dp[i + 1][1] = min(dp[i][0] + 2 * aa + 2 * b, dp[i][1] + aa + 2 * b)
		if a[i] == 1:
			dp[i + 1][0] = maxi
	print(min(dp[n - 1][0] + aa + b, dp[n - 1][1] + 2 * aa + b))


q = int(input())
for query in range(q):
	(n, a, b) = map(int, input().split())
	s = input()
	pod = []
	count = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			pod.append(count)
			count = 1
		else:
			count += 1
	pod.append(count)
	wyn = n * a + 2 * n * b + 2 * b
	for i in range(len(pod)):
		if i % 2 == 0:
			if i == 0 or i == len(pod) - 1:
				wyn -= b * pod[i] - a
			else:
				wyn -= max(0, b * (pod[i] - 1) - 2 * a)
	if len(pod) == 1:
		print((n + 1) * b + n * a)
	else:
		print(wyn)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007

def getAns(count, a, b):
	res1 = count * 2 * b + (count + 1) * a
	res2 = count * b + (count + 3) * a
	return min(res1, res2)
tc = ii1()
for _ in range(tc):
	(n, a, b) = iia()
	s = is1()
	rods = [0] * (n + 1)
	for i in range(n):
		if s[i] == '1':
			rods[i] = 1
			rods[i + 1] = 1
	res = count = 0
	pipe = n
	flag = False
	for i in range(n):
		if rods[i] == 0 and rods[i + 1] == 1 and flag:
			count += 1
			pipe -= count + 1
			res += getAns(count, a, b)
			flag = False
		elif rods[i] == 1 and rods[i + 1] == 0:
			res += b * 2
			count = 0
			flag = True
		elif rods[i] == 0 and flag:
			count += 1
		else:
			res += (rods[i] + 1) * b
	if flag and count:
		res += count * b
	if 1 in rods:
		res += (pipe + 2) * a + b
	else:
		res += pipe * a + b
	print(res)


t = int(input())
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	si = list(s)
	for i in range(1, n):
		si[i] = s[i]
		if s[i - 1] == '1':
			si[i] = '1'
	si += ['0']
	n += 1
	ar = [[0] * 2 for i in range(n)]
	ar[0][0] = b
	num = 10 ** 20
	ar[0][1] = num
	for i in range(1, n):
		ar[i][1] = min(ar[i - 1][1] + a, ar[i - 1][0] + a * 2) + 2 * b
		ar[i][0] = min(ar[i - 1][0] + a, ar[i - 1][1] + a * 2) + b
		if si[i] == '1':
			ar[i][0] = num
	print(ar[-1][0])


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	s = input() + '0'
	(min1, min2) = (c, float('inf'))
	for q in range(a):
		min3 = min(min1 + 2 * b + c * 2, min2 + b + c * 2)
		if s[q + 1] == '0' and s[q] == '0':
			min1 = min(min1 + b + c, min2 + 2 * b + c)
		else:
			min1 = float('inf')
		min2 = min3
	print(min1)


def find_next(A, i, number, n):
	while i < n + 1 and A[i] != number:
		i += 1
	return i
for _ in range(int(input())):
	(n, a, b) = [int(i) for i in input().split()]
	A = [int(i) for i in input()]
	A.append(0)
	cost = b * (n + 1) + n * a
	tccost = 2 * a
	strtc = a
	i = 0
	i = find_next(A, i, 1, n)
	if i == n + 1:
		print(cost)
		continue
	cost += strtc
	h2s = i
	i = find_next(A, i, 0, n)
	cost += (i - h2s + 1) * b
	while i < n + 1:
		prev = i
		i = find_next(A, i, 1, n)
		if i == n + 1:
			break
		if i - prev == 1:
			pass
		else:
			cost += min(tccost, b * (i - prev - 1))
		h2s = i
		i = find_next(A, i, 0, n)
		cost += (i - h2s + 1) * b
	cost += strtc
	print(cost)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	suf = [-1] * n
	t = n
	for i in range(n - 1, -1, -1):
		suf[i] = t
		if s[i] == '1':
			t = i
	(i, f) = (0, 0)
	ans = a * n + b * (n + 1)
	while i < n:
		if s[i] == '1':
			if f == 0:
				ans += a + b
				f = 1
			if suf[i] == n:
				ans += a + b
				break
			if suf[i] - i <= 2:
				ans += (suf[i] - i) * b
			elif (suf[i] - i - 2) * b < 2 * a:
				ans += (suf[i] - i) * b
			else:
				ans += a + b
				f = 0
		i = suf[i]
	print(ans)


R = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, a, b) = R()
	s = input()
	(low, high) = ([0] * (n + 1), [0] * (n + 1))
	low[-1] = b
	high[-1] = 10 ** 15
	for i in range(n):
		if '1' == s[i]:
			high[i] = high[i - 1] + a + 2 * b
			low[i] = 10 ** 15
		else:
			high[i] = min(high[i - 1] + a + 2 * b, low[i - 1] + 2 * a + 2 * b)
			low[i] = min(low[i - 1] + a + b, high[i - 1] + 2 * a + b)
	print(low[n - 1])


from collections import *

def cost(h):
	if h == 3:
		return 2 * a
	else:
		return a + b if h == 1 else a + 2 * b

def dp():
	mem = defaultdict(lambda : float('inf'))
	(mem[0, 1], mem[0, 2]) = (cost(1) + b, cost(3) + 3 * b)
	for i in range(1, n):
		if s[i] == '0':
			if s[i - 1] == '1':
				mem[i, 1] = mem[i - 1, 2] + cost(1) + a
			else:
				mem[i, 1] = mem[i - 1, 1] + cost(1)
			mem[i, 2] = mem[i - 1, 2] + cost(2)
		elif s[i - 1] == '0':
			mem[i, 2] = cost(2) + min(a + b + mem[i - 1, 1], mem[i - 1, 2])
		else:
			mem[i, 2] = cost(2) + mem[i - 1, 2]
	return mem[n - 1, 1]
for i in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	print(dp())


T = int(input())
for _ in range(T):
	(n, a, b) = map(int, input().split())
	s = input()
	cost = b
	road = 0
	previousheight = 0
	for c in s:
		road += 1
		if c == '1':
			if road > 2 or (road > 1 and previousheight == 0):
				optionH = 0
				optionL = 0
				pilars = road
				pipelinesH = road
				pipelinesL = road
				if previousheight == 0:
					optionH += 2 * a
					optionL += 2 * a
					pipelinesH -= 1
					pipelinesL -= 1
				else:
					optionL += 4 * a
					pipelinesL -= 2
				optionH += pipelinesH * a
				optionL += pipelinesL * a
				optionH += pilars * 2 * b
				optionL += (pilars + 2) * b
				minOp = min(optionH, optionL)
				cost += minOp
			else:
				cost += road * a + road * 2 * b
			previousheight = 1
			road = 0
	cost += a
	if previousheight == 1:
		cost += a
	cost += (road - 1) * a
	optionL = road * b
	optionH = (road - 1) * 2 * b + b
	minOp = min(optionH, optionL)
	cost += minOp
	print(cost)


t = int(input())
inf = int(1e+18)
for case_num in range(t):
	(n, a, b) = map(int, input().split(' '))
	s = input() + '0'
	f = [0] * (n + 1)
	f[0] = b
	g = [0] * (n + 1)
	g[0] = inf
	for i in range(n):
		g[i + 1] = min(f[i] + 2 * a, g[i] + a) + 2 * b
		f[i + 1] = min(f[i] + a, g[i] + 2 * a) + b if s[i] == '0' and s[i + 1] == '0' else inf
	print(f[n])


ans = []
round = int(input())
while round > 0:
	register = {'high': 0, 'half': 0, 'low': 0}
	[road_len, pp_cost, plr_cost] = list(map(int, input().split()))
	road = [int(i) for i in input()]
	trade_off = 1
	while 2 * pp_cost > trade_off * plr_cost:
		trade_off += 1
	trade_off += 1
	counter = 0
	pre = -1
	for i in range(len(road)):
		cur = road[i]
		if cur == 1 and pre == 0:
			if register['high'] == 0:
				register['low'] += counter - 1
				register['high'] += 1
				register['half'] += 1
				counter = 0
			else:
				register['high'] += 1
				if counter >= trade_off:
					register['low'] += counter - 2
					register['half'] += 2
				else:
					register['high'] += counter
				counter = 0
		elif i == len(road) - 1:
			if register['high'] == 0:
				register['low'] += counter + 1
			else:
				register['half'] += 1
				register['low'] += counter
		elif cur == 0:
			counter += 1
		elif cur == 1:
			register['high'] += 1
			counter = 0
		pre = cur
	pipelines = register['high'] + 2 * register['half'] + register['low']
	pillars = (4 * register['high'] + 3 * register['half'] + 2 * register['low'] - 2) / 2 + 2
	cost = pipelines * pp_cost + pillars * plr_cost
	ans.append(cost)
	round -= 1
for i in ans:
	print(int(i))


t = int(input())
an = []
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	m = n * a + (n + 1) * b
	y = []
	l = 0
	for i in range(n):
		if s[i] == '0':
			l += 1
		elif l != 0:
			y += [l]
			l = 0
	y += [l]
	m += (len(y) - 1 + s.count('1')) * b
	if len(y) != 1:
		m += 2 * a
		for j in range(1, len(y) - 1):
			m += min((y[j] - 1) * b, 2 * a)
	an.append(m)
for i in an:
	print(i)


import sys
read_line = lambda : sys.stdin.readline().strip()
read_intmap = lambda : map(int, read_line().split())

def testCase():
	(n, a, b) = read_intmap()
	cross = tuple(map(int, read_line()))
	cost = n * a + (n + 1) * b
	dp = [[0] * (n + 1) for i in range(2)]
	upper = max(a, b) * n * 20
	dp[0][-1] = 0
	dp[1][-1] = upper
	for i in range(n - 1, 0, -1):
		if cross[i] or cross[i - 1]:
			dp[0][i] = upper
		else:
			dp[0][i] = min(dp[1][i + 1] + a, dp[0][i + 1])
		dp[1][i] = b + min(dp[0][i + 1] + a, dp[1][i + 1])
	dp[0][0] = min(dp[1][1] + a, dp[0][1])
	print(dp[0][0] + cost)
t = 1
t = int(input())
for i in range(t):
	testCase()


def main():

	def solve():
		(n, a, b) = map(int, input().split())
		ss = input()
		cost = 0
		for i in range(n):
			if ss[i] == '1':
				last = i
				cost += a * (i + 1) + b * i
				break
		else:
			print(a * n + b * (n + 1))
			return
		for i in range(last, n):
			if ss[i] == '1' or ss[i - 1] == '1':
				high = (i - last) * (a + 2 * b)
				low = (i - last) * (a + b) + a * 2 + b
				cost += min(high, low)
				last = i
		cost += (n + 1 - last) * (a + b) + b
		print(cost)
	q = int(input())
	for _ in range(q):
		solve()

def __starting_point():
	main()
__starting_point()


from math import *
from sys import *
from collections import defaultdict
M = 10 ** 9 + 7

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def factor(n):
	potentional_p = 3
	itog_list = {}
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			if n in itog_list:
				itog_list[n] += 1
			else:
				itog_list[n] = 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			if potentional_p in itog_list:
				itog_list[potentional_p] += 1
			else:
				itog_list[potentional_p] = 1
		potentional_p += 2
	return itog_list
t = int(stdin.readline())
for _ in range(t):
	(n, g, p) = list(map(int, stdin.readline().split()))
	s = input()
	res = 0
	temp = ''
	ss = ''
	for x in s:
		if x == '1':
			temp += x
		else:
			if len(temp) >= 1:
				res += (g + 2 * p) * (len(temp) - 1)
				ss += '1'
			temp = ''
			ss += '0'
	s = ss
	lft = s.find('1')
	if lft == -1:
		res += (1 + len(s)) * p + len(s) * g
		print(res)
		continue
	res += (1 + lft) * g + lft * p
	s = s[lft:]
	s = s[::-1]
	lft = s.find('1')
	res += (1 + lft) * g + lft * p
	s = s[lft:][::-1]
	if s == '1':
		res += 4 * p + g
		print(res)
		continue
	arr = s.split('1')
	arr = arr[1:-1]
	for x in arr:
		val = min(2 * g, (len(x) - 1) * p)
		res += 4 * p + val + len(x) * g + (len(x) - 1) * p
	res += s.count('1') * g
	res += 4 * p
	print(res)


def solve():
	(N, A, B) = [int(i) for i in input().split(' ')]
	road = input()
	cost = A * N + (N + 1) * B + road.count('1') * B + 2 * road.count('01') * A + road.count('01') * B
	maxWorthGap = int(A / B)
	zeros = 0
	wasOne = False
	for i in range(N):
		if road[i] == '0' and wasOne:
			zeros += 1
		elif road[i] == '1':
			wasOne = True
			delta = (zeros - 1) * B - 2 * A
			if zeros > 0 and delta < 0:
				cost += delta
			zeros = 0
	print(cost)
Q = int(input())
for _ in range(Q):
	solve()


import math
import sys

def main():
	(n, a, b) = map(int, input().split())
	string = str(input())
	ans = 0
	ans += b + b
	for i in range(1, n):
		if string[i - 1] == '0' and string[i] == '0':
			ans += b
		else:
			ans += 2 * b
	pipes = 0
	start = -1
	end = -1
	for i in range(n - 1):
		if string[i] == '1':
			start = i
			break
	for i in range(n - 1, -1, -1):
		if string[i] == '1':
			end = i
			break
	if start == end and end == -1:
		print(n * a + ans)
		return
	pipes = (start + 1) * a
	pipes += (n - end) * a
	while start < end:
		while start < end and string[start] == '1':
			pipes += a
			start += 1
		cnt = 0
		if start == end:
			break
		while start < end and string[start] == '0':
			cnt += 1
			start += 1
		pipes += min(b * (cnt - 1) + a * cnt, (cnt + 2) * a)
	print(ans + pipes + a)
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


q = int(input())
for query in range(q):
	(n, a, b) = map(int, input().split())
	s = input()
	(cost, up) = (a * n + (n + 1) * b, False)
	i = 0
	while i < n - 1:
		if up:
			cost += b
		elif s[i] == '0' and s[i + 1] == '1' and (not up):
			cost += a
			up = True
		if up and s[i] == '0' and (s[i + 1] == '0'):
			tempc = i
			while i < n and s[i] == '0':
				i += 1
			if i == n:
				cost += a
				up = False
				i -= 1
			elif (i - tempc - 1) * b > 2 * a:
				cost += a
				up = False
				i -= 1
			else:
				cost += (i - tempc - 1) * b
		else:
			i += 1
	if s[n - 2] == '1':
		cost += b
	if up:
		cost += a
	print(cost)


inf = 1000000000000000000
t = int(input())
while t > 0:
	t -= 1
	(n, pip_price, pil_price) = map(int, input().split())
	ls = list(input())
	dp = [[0, 0] for i in range(n + 5)]
	dp[0][1] = inf
	dp[0][0] = pip_price + pil_price
	for i in range(1, len(ls)):
		if ls[i] == '1':
			dp[i][0] = inf + 1
			dp[i][1] = min(dp[i - 1][0] + 2 * pip_price + 2 * pil_price, dp[i - 1][1] + 2 * pil_price + pip_price)
		else:
			dp[i][0] = min(dp[i - 1][0] + pip_price + pil_price, dp[i - 1][1] + 2 * pip_price + 2 * pil_price)
			dp[i][1] = min(dp[i - 1][0] + 2 * pip_price + pil_price, dp[i - 1][1] + 2 * pil_price + pip_price)
	print(dp[n - 1][0] + pil_price)


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')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

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

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
from math import inf
for _ in range(int(input()) if True else 1):
	(n, a, b) = map(int, input().split())
	s = input()
	dp = [[inf] * 2 for __ in range(n + 69)]
	dp[0][0] = b
	for i in range(n):
		if s[i] == '1':
			dp[i + 1][1] = dp[i][1] + a + 2 * b
		else:
			dp[i + 1][0] = min(dp[i][1] + b + 2 * a, dp[i][0] + b + a)
			dp[i + 1][1] = min(dp[i][1] + a + 2 * b, dp[i][0] + 2 * a + 2 * b)
	print(dp[n][0])


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = str(input())
	last_seen = '0'
	count = 0
	counts = []
	for i in range(len(s)):
		if s[i] == last_seen:
			count += 1
		else:
			counts.append(count)
			last_seen = s[i]
			count = 1
	counts.append(count)
	if len(counts) == 1:
		print((n + 1) * b + n * a)
		continue
	total = 0
	total += counts[0] * b + (counts[0] + 1) * a
	total += counts[-1] * b + (counts[-1] + 1) * a
	counts = counts[1:-1]
	ind = 0
	while True:
		total += 2 * (counts[ind] + 1) * b + counts[ind] * a
		if ind == len(counts) - 1:
			break
		cost1 = (counts[ind + 1] - 1) * b + (counts[ind + 1] + 2) * a
		cost2 = 2 * (counts[ind + 1] - 1) * b + counts[ind + 1] * a
		total += min(cost1, cost2)
		ind += 2
	print(total)


import math
import sys
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from sys import stdin, stdout
from collections import defaultdict
inp = lambda : int(stdin.readline())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, stdin.readline().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
for _ in range(inp()):
	(n, a, b) = mulip()
	s = input()
	dp = [[pow(10, 18)] * 2 for i in range(n + 1)]
	dp[0][0] = b
	for i in range(n):
		if s[i] == '0':
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + a + b)
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + 2 * (a + b))
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a + 2 * b)
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 2 * a + b)
		else:
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a + 2 * b)
	print(dp[n][0])


import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	(n, a, b) = nm()
	s = list(map(int, list(input())))
	dp = [[10 ** 18] * 2 for i in range(n + 1)]
	dp[0][0] = b
	for i in range(n):
		if s[i]:
			dp[i + 1][1] = dp[i][1] + a + b * 2
		else:
			dp[i + 1][0] = min(dp[i][0] + a + b, dp[i][1] + a * 2 + b)
			dp[i + 1][1] = min(dp[i][0] + 2 * a + 2 * b, dp[i][1] + a + b * 2)
	print(dp[n][0])
	return
T = ni()
for _ in range(T):
	solve()


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = list(map(int, list(input())))
	g = list()
	cur = 0
	count = 0
	for x in s:
		if x == cur:
			count += 1
		else:
			g.append(count)
			count = 1
			cur = x
	ones = sum(s)
	g.append(count)
	if len(g) == 1:
		print(len(s) * a + (len(s) + 1) * b)
		continue
	(costa, costb, costc) = (0, 0, 0)
	costa += len(s) * a
	costb += (len(s) + 1) * b
	upar = 0
	neeche = 0
	g = g[1:-1]
	for i in range(0, len(g), 2):
		costb += (g[i] + 1) * b
	for i in range(1, len(g), 2):
		k = g[i]
		if k == 1:
			continue
		upar = b * (k - 1)
		neeche = 2 * a
		costc += min(upar, neeche)
	cost = costa + costb + costc + 2 * a
	print(cost)


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

def f(i, j):
	return a[i][j] == a[i + 1][j] == a[i][j + 1] == a[i + 1][j + 1] == 1
q = int(input())
for qq in range(q):
	(n, a, b) = mp()
	s = input()
	dp_u = [0] * (n + 1)
	dp_d = [0] * (n + 1)
	dp_u[0] = 10 ** 20
	dp_d[0] = b
	for i in range(1, n):
		dp_u[i] = min(dp_u[i - 1] + a, dp_d[i - 1] + 2 * a) + 2 * b
		if s[i] == '0' and s[i - 1] == '0':
			dp_d[i] = min(dp_u[i - 1] + 2 * a, dp_d[i - 1] + a) + b
		else:
			dp_d[i] = 10 ** 20
	print(min(dp_d[n - 1] + a, dp_u[n - 1] + 2 * a) + b)


from math import inf
t = int(input())
for w in range(t):
	(n, a, b) = map(int, input().split())
	dp = [[inf for i in range(n + 1)] for j in range(2)]
	s = input()
	dp[0][0] = b
	for i in range(1, n + 1):
		if s[i - 1] == '0':
			dp[0][i] = min(dp[0][i - 1] + a + b, dp[1][i - 1] + 2 * a + b)
			dp[1][i] = min(dp[0][i - 1] + 2 * (a + b), dp[1][i - 1] + a + 2 * b)
		else:
			dp[1][i] = dp[1][i - 1] + a + 2 * b
	print(dp[0][n])


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input().strip()
	ans = (n + 1) * b + n * a
	if '1' in s:
		ans += 2 * a
		s = s[s.find('1'):s.rfind('1') + 1]
		t = [0] * (len(s) + 1)
		for i in range(len(s)):
			x = int(s[i])
			t[i] = max(t[i], x)
			t[i + 1] = max(t[i + 1], x)
		i = 0
		while i < len(t):
			j = i + 1
			while j < len(t) and t[i] == t[j]:
				j += 1
			if t[i]:
				ans += b * (j - i)
			else:
				ans += min(b * (j - i), 2 * a)
			i = j
	print(ans)


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	INF = 10 ** 18
	dp = [[INF] * 2 for i in range(n + 1)]
	dp[0][0] = b
	for i in range(1, n + 1):
		if i < n and (s[i] == '1' or s[i - 1] == '1'):
			dp[i][0] = INF
			dp[i][1] = min(dp[i - 1][0] + 2 * a, dp[i - 1][1] + a) + b * 2
		else:
			dp[i][0] = min(dp[i - 1][1] + 2 * a, dp[i - 1][0] + a) + b
			dp[i][1] = min(dp[i - 1][1] + a, dp[i - 1][0] + 2 * a) + 2 * b
	print(dp[n][0])


t = int(input())
for i in range(t):
	(n, a, b) = [int(x) for x in input().split()]
	s = [int(x) for x in list(input())]
	gas = n
	h = n + 1
	index = -1
	one = -1
	for i in range(n):
		if s[i] == 0:
			if index != -1:
				h += i - index + 1
				gas += 2
				index = -1
				one = i - 1
		elif index == -1:
			index = i
			if one != -1 and 2 * a > (i - one - 2) * b:
				gas -= 2
				h += i - one - 2
	print(gas * a + h * b)


def naiveSolve():
	return

def main():
	t = int(input())
	allans = []
	for _ in range(t):
		(n, a, b) = readIntArr()
		s = input()
		baseCost = n * a + (n + 1) * b
		n += 1
		s2 = [0] * n
		for i in range(n - 1):
			if s[i] == '1':
				s2[i] = s2[i + 1] = 1
		dp = [[inf, inf] for _ in range(n)]
		dp[0][0] = 0
		for i in range(1, n):
			dp[i][1] = min(dp[i - 1][0] + a + b, dp[i - 1][1] + b)
			if s2[i] == 0:
				dp[i][0] = min(dp[i - 1][0], dp[i - 1][1] + a)
		ans = dp[n - 1][0] + baseCost
		allans.append(ans)
	multiLineArrayPrint(allans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

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

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

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

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

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

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


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	d = list(s)
	for i in range(1, n - 1):
		if d[i] == '0' and d[i - 1] == '1' and (d[i + 1] == '1'):
			d[i] = '1'
	i = 0
	while i < n and d[i] == '0':
		i += 1
	k = n - 1
	while k >= 0 and d[k] == '0':
		k -= 1
	j = i
	while j <= k:
		c = 0
		ss = j
		while j <= k and d[j] == '0':
			c += 1
			j += 1
		if c > 1 and (c - 1) * b < 2 * a:
			while ss < j:
				d[ss] = '1'
				ss += 1
		j += 1
	onc = 0
	ii = 0
	while ii < n:
		cc = 0
		while ii < n and d[ii] == '1':
			cc += 1
			ii += 1
		if cc > 0:
			onc += cc + 1
		ii += 1
	onewale = n + 1 - onc
	pillar = (onewale + onc * 2) * b
	cc = 0
	for l in range(1, n):
		if d[l] != d[l - 1]:
			cc += 1
	pipe = (n + cc) * a
	print(pillar + pipe)


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

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

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

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
t = ii()
for j in range(t):
	(n, a, b) = mi()
	s = input()
	if '1' not in s:
		print((n + 1) * b + n * a)
		continue
	d = {}
	i = 0
	while i < n:
		t = 0
		if s[i] != '0':
			pos = i
			while i < n and s[i] == '1':
				t += 1
				i += 1
			d[pos] = [1, t]
		else:
			pos = i
			while i < n and s[i] == '0':
				t += 1
				i += 1
			d[pos] = [0, t]
	st = min(d)
	en = max(d)
	i = 0
	res = 0
	for i in d:
		if i == st:
			res += d[i][1] * b + (d[i][1] + 1) * a
		elif i == en:
			res += 2 * b + d[i][1] * b + (d[i][1] + 1) * a
		elif d[i][0] == 1:
			res += 2 * b * d[i][1] + a * d[i][1]
		elif d[i][0] == 0 and d[i][1] > 1:
			l = 4 * a + 2 * b + a * (d[i][1] - 2) + b * (d[i][1] - 1)
			r = d[i][1] * a + d[i][1] * (2 * b)
			res += min(l, r)
		elif d[i][0] == 0:
			res += d[i][1] * a + d[i][1] * (2 * b)
	print(res)


import sys

def main():
	(n,) = [int(x) for x in sys.stdin.readline().strip().split()]
	INF = 10 ** 20
	for _ in range(n):
		(n, a, b) = [int(x) for x in sys.stdin.readline().strip().split()]
		s = sys.stdin.readline().strip()
		down = [2 * b + a]
		up = [b + 2 * b + 2 * a]
		for c in s[1:]:
			d = down[-1]
			u = up[-1]
			if c == '0':
				down.append(min(d + a + b, u + 2 * a + b))
				up.append(min(d + 2 * a + 2 * b, u + a + 2 * b))
			else:
				down.append(INF)
				up.append(u + a + 2 * b)
		print(down[-1])
main()


from itertools import groupby
T = int(input())
for _ in range(T):
	(n, a, b) = tuple(map(int, input().split()))
	s = input()
	G = [(k, len(list(g)), False) for (k, g) in groupby(s)]
	G[-1] = (G[-1][0], G[-1][1], True)
	q = 0
	state = 0
	for (k, L, last) in G:
		if state == 0 and k == '0':
			if last:
				q += L * a
				q += (L + 1) * b
			else:
				q += (L + 1) * a
				q += L * b
		elif state == 0 and k == '1':
			q += L * a
			q += L * 2 * b
			state = 1
		elif state == 1 and k == '0':
			if last:
				q += (L + 1) * a
				q += (L + 2) * b
			else:
				q1 = (L + 2) * a + (L + 1) * b
				q2 = L * a + 2 * L * b
				q += min(q1, q2)
			state = 0
	print(q)


def solve():
	l = list(map(int, input().strip().split()))
	s = input()
	n = l[0]
	a = l[1]
	b = l[2]
	dp = []
	for _ in range(n + 10):
		dp.append([float('inf'), float('inf')])
	dp[0][0] = b
	dp[0][1] = float('inf')
	for i in range(n):
		if s[i] == '0':
			dp[i + 1][0] = min(dp[i][0] + a + b, dp[i][1] + 2 * a + b)
			dp[i + 1][1] = min(dp[i][0] + 2 * a + 2 * b, dp[i][1] + a + 2 * b)
		else:
			dp[i + 1][0] = float('inf')
			dp[i + 1][1] = dp[i][1] + a + 2 * b
	print(dp[n][0])
t = int(input())
for _ in range(t):
	solve()


import math, sys
from collections import defaultdict, deque
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

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

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

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

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_lt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i - 1
	else:
		return len(a) - 1

def main():
	try:
		(n, a, b) = In()
		s = list(map(int, list(Sn()))) + [0]
		dp = [[b, float('inf')]]
		ok = False
		l = [0]
		for i in range(n):
			l.append(max(s[i], s[i + 1]))
		dp = [[b, float('inf')]]
		for i in range(1, len(l)):
			dp.append([INF, INF])
			if l[i] == 0:
				if l[i - 1] == 1:
					dp[i][0] = min(dp[i][0], dp[i - 1][1] + (2 * a + b))
					dp[i][1] = min(dp[i][1], dp[i - 1][1] + (a + 2 * b))
				elif l[i - 1] == 0:
					dp[i][0] = min(dp[i][0], dp[i - 1][1] + (2 * a + b), dp[i - 1][0] + (a + b))
					dp[i][1] = min(dp[i][1], dp[i - 1][0] + (2 * a + 2 * b), dp[i - 1][1] + (2 * b + a))
			elif l[i - 1] == 0:
				dp[i][1] = min(dp[i][1], dp[i - 1][0] + (2 * a + 2 * b), dp[i - 1][1] + (a + 2 * b))
			else:
				dp[i][1] = dp[i - 1][1] + (2 * b + a)
		print(dp[-1][0])
	except:
		pass
M = 998244353
P = 1000000007
INF = float('inf')
for _ in range(I()):
	main()


t = int(input())
for j in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	k = 0
	z = 0
	for i in range(n):
		if s[i] == '0':
			z += 1
		else:
			if z == 1:
				if i == z:
					k += 3 * b + 2 * a
				else:
					k += a + 2 * b
			elif z > 1:
				if i == z:
					alter_1 = 3 * b + 2 * a + (z - 1) * (a + 2 * b)
					alter_2 = 2 * b + a + (z - 2) * (a + b) + 2 * a + 2 * b
				else:
					alter_1 = z * (a + 2 * b)
					alter_2 = 2 * a + b + (z - 2) * (a + b) + 2 * a + 2 * b
				k += min(alter_1, alter_2)
			k += a + 2 * b
			z = 0
	if z == n:
		k = b + z * (a + b)
	else:
		alter_1 = (z - 1) * (a + 2 * b) + 2 * a + b
		alter_2 = 2 * a + b + (z - 1) * (a + b)
		k += min(alter_1, alter_2)
	print(k)


def mi():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, a, b) = mi()
	s = list(map(int, input()))
	ans = (a + b) * n + b
	if 1 not in s:
		print(ans)
		continue
	i1 = s.index(1)
	i2 = n - 1 - s[::-1].index(1)
	ans += 2 * a + (i2 - i1 + 2) * b
	i = i1
	while i < i2:
		enter = False
		while i < i2 and s[i] == 1:
			enter = True
			i += 1
		start = i
		while i < i2 and s[i] == 0:
			enter = True
			i += 1
		if i < n and s[i] == 1 and (s[i - 1] == 0):
			enter = True
			if 2 * a - b * (i - start - 1) < 0:
				ans += 2 * a - b * (i - start - 1)
		if not enter:
			break
	print(ans)


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, gas, pipe) = value()
	a = [int(i) for i in input()]
	pill = [1] * (n + 1)
	for i in range(n - 1):
		if a[i]:
			pill[i + 1] += 1
		elif a[i + 1]:
			pill[i + 1] += 1
	ans = n * gas + sum(pill) * pipe
	have = []
	c = 1
	for i in range(1, len(pill)):
		if pill[i] == 1:
			c += 1
		elif pill[i - 1] == 1:
			have.append(c)
			c = 0
	have.append(c)
	if len(have) > 1:
		ans += 2 * gas
		have.pop()
	have = have[1:]
	for i in have:
		if i * pipe * 2 < i * pipe + gas * 2:
			ans += i * pipe
		else:
			ans += gas * 2
	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().rstrip('\r\n')
for j in range(int(input())):
	(n, a, b) = map(int, input().split())
	vals = [int(k) for k in input()]
	ones = []
	cost = 0
	for s in range(n):
		if vals[s] == 1:
			ones.append(s)
	if len(ones) > 0:
		contzerf = 0
		contzerl = 0
		for s in range(n):
			if vals[s] == 0:
				contzerf += 1
			else:
				break
		for s in range(n - 1, -1, -1):
			if vals[s] == 0:
				contzerl += 1
			else:
				break
		cost += (a + b) * (contzerf + contzerl) + 3 * a + 2 * b
	else:
		cost = a * n + b * (n + 1)
	if len(ones) > 1:
		for s in range(len(ones) - 1):
			if s != len(ones) - 2:
				zeros = ones[s + 1] - ones[s] - 1
				mincost = (a + 2 * b) * (zeros + 1)
				for i in range(zeros):
					a1 = i
					a2 = zeros - i
					if a1 > 0:
						c1 = 2 * a + a * (zeros + 1)
						c1 += a1 * b + a2 * 2 * b + 2 * b
					else:
						c1 = a * (zeros + 1)
						c1 += a1 * b + a2 * 2 * b + 2 * b
					if c1 < mincost:
						mincost = c1
				cost += mincost
			else:
				zeros = ones[s + 1] - ones[s] - 1
				mincost = (a + 2 * b) * (zeros + 1) + 2 * b
				for i in range(zeros):
					a1 = i
					a2 = zeros + 1 - i
					if a1 > 0:
						c1 = 2 * a
						c1 += a * (zeros + 1)
						c1 += a1 * b + a2 * 2 * b + 2 * b
					else:
						c1 = a * (zeros + 1)
						c1 += a1 * b + a2 * 2 * b + 2 * b
					if c1 < mincost:
						mincost = c1
				cost += mincost
	elif len(ones) == 1:
		cost += 2 * b
	print(cost)


import math
t = int(input())
for _ in range(t):
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	gap = math.ceil(2 * a / b) + 1
	cost = b
	state = 0
	b2 = 2 * b
	streak0 = 0
	for i in range(n - 1):
		if s[i] == '1':
			streak0 = 0
		else:
			streak0 += 1
		if s[i + 1] == '1':
			if streak0 >= gap and state:
				cost -= (streak0 - 1) * b
				cost += 2 * a
			if not state:
				state = 1
				cost += a
		cost += a + b
		if state:
			cost += b
	cost += a + b
	streak0 += 1
	if state:
		cost -= (streak0 - 1) * b
		cost += a
	print(cost)


q = int(input())
for Q in range(q):
	(n, a, b) = tuple(map(int, input().split()))
	s = input()
	if s == '0' * n:
		print(n * a + (n + 1) * b)
		continue
	cost = n * a + 2 * n * b
	i = 0
	while s[i] == '0':
		cost -= b
		i += 1
	cost += a
	while i < n:
		while i < n and s[i] == '1':
			i += 1
		start = i
		while i < n and s[i] == '0':
			i += 1
		end = i - 1
		if i == n:
			cost += a - b * (end - start)
		elif (end - start) * b > 2 * a:
			cost = cost - (end - start) * b + 2 * a
	print(cost + b)


t = int(input())
for _ in range(t):
	(n, pipeCost, pillarCost) = map(int, input().split())
	road = input()
	cost = 0
	freq = []
	curr = '0'
	currFreq = 0
	for i in road:
		if i == curr:
			currFreq += 1
		else:
			freq.append(currFreq)
			curr = i
			currFreq = 1
	freq.append(currFreq)
	if len(freq) == 3:
		cost += pillarCost * freq[0]
		cost += pillarCost * 2 * (freq[1] + 1)
		cost += pillarCost * freq[2]
		cost += pipeCost * (sum(freq) + 2)
	elif len(freq) == 1:
		cost += pillarCost * (freq[0] + 1)
		cost += pipeCost * freq[0]
	else:
		level = True
		switch = 0
		cost += pipeCost * sum(freq)
		for i in range(len(freq)):
			if i % 2 == 0:
				if level:
					if i == 0 or i == len(freq) - 1:
						cost += pillarCost * freq[i]
					else:
						cost += pillarCost * (freq[i] - 1)
				elif i == len(freq) - 1:
					level = True
					cost += pillarCost * freq[i]
				elif (freq[i] - 1) * pillarCost > 2 * pipeCost:
					level = True
					cost += pillarCost * (freq[i] - 1)
				else:
					cost += pillarCost * 2 * (freq[i] - 1)
			elif level:
				level = False
				switch += 1
				cost += pillarCost * 2 * (freq[i] + 1)
			else:
				cost += pillarCost * 2 * (freq[i] + 1)
		cost += 2 * switch * pipeCost
	print(cost)


for _ in range(int(input())):
	(n, a, b) = list(map(int, input().split()))
	s = input()
	if s == '0' * n:
		print(a * n + b * n + b)
		continue
	ans = 0
	ind = 0
	ind2 = n - 1
	pref = 0
	suf = 0
	while ind2 >= 0 and s[ind2] == '0':
		ind2 -= 1
		suf += 1
	while ind < n and s[ind] == '0':
		ind += 1
		pref += 1
	while ind <= ind2:
		if s[ind] == '0':
			size = 0
			while ind <= ind2 and s[ind] == '0':
				ind += 1
				size += 1
			ans += min((size - 1) * b + size * a + 2 * a, size * a + 2 * b * (size - 1))
		else:
			size = 0
			while ind <= ind2 and s[ind] == '1':
				ind += 1
				size += 1
			ans += (size + 1) * b * 2 + size * a
	ans += pref * b + pref * a + a
	ans += suf * b + suf * a + a
	print(ans)


T = int(input())
for k in range(T):
	(n, a, b) = map(int, input().split())
	s = input()
	dp = [[0, 0] for k in range(n + 1)]
	dp[0][0] = b
	dp[0][1] = float('inf')
	for l in range(1, n + 1):
		if s[l - 1] == '0':
			dp[l][0] = min(dp[l - 1][0] + a + b, dp[l - 1][1] + 2 * a + 2 * b)
			dp[l][1] = min(dp[l - 1][1] + a + 2 * b, dp[l - 1][0] + 2 * a + 2 * b)
		else:
			dp[l][0] = float('inf')
			dp[l][1] = min(dp[l - 1][1] + a + 2 * b, dp[l - 1][0] + 2 * a + 2 * b)
	print(dp[n][0])


T = int(input())
for test_num in range(T):
	(n, a, b) = map(int, input().split())
	st = 0
	ln = input()
	per = 0
	cx = 0
	cn = 0
	i = 0
	while i < len(ln):
		if ln[i] == '1':
			if cn > 0:
				if per > 0:
					st = st + min(cn * a + (cn + 1) * 2 * b, (cn + 2) * a + (cn + 3) * b)
				else:
					st = st + (i + 1) * a + (i + 2) * b
				cx = 1
				cn = 0
			else:
				cx = cx + 1
			per = per + 1
		elif cn > 0:
			cn = cn + 1
		else:
			if per > 0:
				st = st + cx * a + (cx - 1) * 2 * b
			cn = 1
			cx = 0
		i = i + 1
	if per > 0:
		st = st + (cn + 1) * a + (cn + 2) * b
	else:
		st = st + i * a + (i + 1) * b
	print(st)


def main():
	T = int(input())
	for _ in range(T):
		(n, a, b) = [int(s) for s in input().split()]
		s = [int(x) for x in list(input())]
		lengths = []
		current = 0
		length = 0
		for segment in s:
			if segment == current:
				length += 1
			else:
				lengths.append(length)
				length = 1
				current = segment
		lengths.append(length)
		if len(lengths) == 1:
			print((n + 1) * b + n * a)
			continue
		sol = (lengths[0] + 1) * a + lengths[0] * b
		sol += (lengths[-1] + 1) * a + (lengths[-1] + 2) * b
		current = 1
		for length in lengths[1:-1]:
			if current == 0 and length > 1:
				down = (length + 1) * b + (length + 2) * a
				up = length * 2 * b + length * a
				sol += min(up, down)
			else:
				sol += length * 2 * b + length * a
			current = (current + 1) % 2
		print(sol)
main()


from sys import stdin
t = int(stdin.readline().strip())
for Ta in range(t):
	(n, a, b) = list(map(int, stdin.readline().strip().split()))
	s = stdin.readline().strip()
	dp = [[10 ** 15, 10 ** 15] for i in range(n)]
	dp[0][0] = a + b
	dp[0][1] = b + 2 * a
	for i in range(1, n):
		if s[i] == '0':
			dp[i][0] = min(dp[i - 1][0] + a + b, dp[i - 1][1] + 2 * a + 2 * b)
			dp[i][1] = min(dp[i - 1][0] + b + 2 * a, dp[i - 1][1] + 2 * b + a)
		else:
			dp[i][1] = dp[i - 1][1] + 2 * b + a
	print(dp[-1][0] + b)


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

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

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

def nu():
	return int(input())

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

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007
yp = 0

def solve():
	t = nu()
	for tt in range(t):
		(n, a, b) = num()
		x = list(input())
		cc = 1
		ll = x[0]
		s = []
		for i in range(1, n):
			if x[i] == ll:
				cc += 1
			else:
				s.append((ll, cc))
				cc = 1
				ll = x[i]
		s.append((ll, cc))
		ss = b
		p1 = a
		p2 = 2 * a
		t1 = b
		t2 = 2 * b
		last = 1
		for i in range(0, len(s) - 1):
			if s[i][0] == '0':
				if last == 1:
					cn = s[i][1]
					ss += (cn - 1) * p1 + (cn - 1) * t1 + p2 + t2
					last = 2
				else:
					cn = s[i][1]
					if cn == 1:
						ss += p1 + t2
					else:
						o1 = (cn - 2) * p1 + (cn - 1) * t1 + p2 * 2 + t2
						o2 = cn * p1 + cn * t2
						if o1 <= o2:
							last = 2
							ss += o1
						else:
							last = 2
							ss += o2
			else:
				cn = s[i][1]
				ss += cn * p1 + cn * t2
				last = 2
		if last == 1:
			cn = s[len(s) - 1][1]
			ss += cn * b + cn * a
		else:
			cn = s[len(s) - 1][1]
			ss += (cn - 1) * a + cn * b + 2 * a
		print(ss)
solve()


import sys
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()
for t in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	arr = [['0', 1]]
	for i in range(1, n):
		if s[i] == arr[-1][0]:
			arr[-1][1] += 1
		else:
			arr.append([s[i], 1])
	if len(arr) == 1:
		pipe = n
		pillar = n + 1
	else:
		pipe = n + 2
		pillar = arr[0][1] + arr[-1][1] + 2 * (n + 1 - arr[0][1] - arr[-1][1])
		for (i, j) in arr[1:-1]:
			if i == '0' and j >= 2 and ((j - 1) * b > 2 * a):
				pipe += 2
				pillar -= j - 1
	print(pipe * a + pillar * b)


def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		(N, a, b) = map(int, input().split())
		S = input().rstrip('\n')
		dp = [[0] * 2 for _ in range(N + 1)]
		inf = int(float(10 ** 20))
		dp[0][0] = b
		dp[0][1] = inf
		for i in range(N):
			if S[i] == '0':
				dp[i + 1][0] = min(dp[i][0] + a + b, dp[i][1] + 2 * a + b)
				dp[i + 1][1] = min(dp[i][0] + a * 2 + 2 * b, dp[i][1] + a + 2 * b)
			else:
				dp[i + 1][0] = inf
				dp[i + 1][1] = dp[i][1] + a + 2 * b
		print(dp[-1][0])
main()


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, a, b) = map(int, input().split())
	l = input().strip()
	p = 0
	cur = 0
	ans = 0
	if '1' not in l:
		print(b * (n + 1) + a * n)
	else:
		while p < n:
			if l[p] == '1':
				ans += b * p + 2 * b + a * (p + 1)
				break
			else:
				p += 1
		cur = p
		while p < n:
			if l[p] == '1':
				diff = p - cur
				if diff <= 2:
					ans += 2 * b * diff + a * diff
					cur = p
					p += 1
				else:
					ans1 = 2 * b * diff + a * diff
					ans2 = 2 * b * 2 + b * (diff - 2) + a * (diff + 2)
					ans += min(ans1, ans2)
					cur = p
					p += 1
			else:
				p += 1
		diff = n - cur
		ans += 2 * b + (diff - 1) * b + a * (diff + 1)
		print(ans)


import sys

def input():
	return sys.stdin.readline()[:-1]
t = int(input())
ans = []
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	res = [b, 10 ** 30]
	for i in range(n):
		tmp = []
		if s[i] == '0':
			tmp.append(min(res[0] + a + b, res[1] + 2 * a + b))
			tmp.append(min(res[1] + a + 2 * b, res[0] + 2 * a + 2 * b))
		else:
			tmp.append(10 ** 30)
			tmp.append(res[1] + a + 2 * b)
		res = tmp
	ans.append(res[0])
print(*ans, sep='\n')


T = int(input())
for _ in range(T):
	(n, a, b) = map(int, input().split())
	s = [int(x) for x in input()]
	ans = (n + 1) * b
	k = 0
	fp = True
	for i in range(len(s)):
		if s[i] == 0:
			k += 1
		else:
			if fp:
				fp = False
				ans += (k + 2) * a + 2 * b
			elif k == 0:
				ans += a + b
			else:
				ans += min((k + 3) * a + 2 * b, (k + 1) * (a + b))
			k = 0
	if fp:
		ans += k * a
	else:
		ans += (k + 1) * a
	print(ans)


import sys
mod = 1000000007

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

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

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

def print_array(a):
	print(' '.join(map(str, a)))

def main():
	for _ in range(int(input())):
		(n, a, b) = get_ints()
		s = input()
		(cost, cnt, i) = (n * (a + b) + b, 0, 0)
		for i in range(n - 1):
			if s[i] == '1' or s[i + 1] == '1':
				cnt += 1
		if cnt > 0:
			cost += 2 * a + cnt * b
			i = s.index('1')
			j = n - 1
			while s[j] == '0':
				j -= 1
			cnt = 0
			while i <= j:
				if s[i] == '0':
					cnt += 1
				else:
					if cnt > 0:
						cost += min((cnt - 1) * b, 2 * a)
					cnt = 0
				i += 1
		print(cost)
main()


C = []
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	pre = None
	pos = [None, None]
	genc = False
	x = 0
	cost = (a + b) * n + b
	for (i, cur) in enumerate(input()):
		if pre == None:
			pre = '0'
			continue
		if cur == '0':
			if pre == '0':
				if pos[0] == None and genc:
					x += 1
				elif genc:
					cost += (pos[1] - pos[0] + 2) * b
					x = 1
					pos[0] = None
					pos[1] = None
			else:
				pos[1] = i - 1
		elif pre == '0':
			if pos[0] == None:
				if genc:
					cost += min(b * x, 2 * a)
					x = 0
				else:
					genc = True
				pos[0] = i
		pre = cur
	if genc:
		if pos[0] is not None:
			cost += 2 * a + (pos[1] - pos[0] + 2) * b
		else:
			cost += 2 * a
	C.append(cost)
for c in C:
	print(c)


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	M = min(a, b)
	i = s.find('1')
	if i != -1:
		Cost = i * (a + b) + a + 2 * b
	else:
		Cost = n * a + (n + 1) * b
		print(Cost)
		continue
	prev = i
	while i < n:
		while i < n and s[i] == '1':
			prev = i
			i += 1
			Cost += 2 * b + a
		while i < n and s[i] != '1':
			i += 1
		if i == n:
			diff = i - prev - 1
			Cost += diff * a
			Cost += (diff - 1) * b
			Cost += a + b
		else:
			diff = i - prev - 1
			Cost += diff * a
			Cost += (diff - 1) * b
			Cost += min(2 * a, (diff - 1) * b) + 2 * b
	print(Cost)


T = int(input())
for _ in range(T):
	(n, a, b) = map(int, input().split())
	s = list(map(int, input()))
	if 1 not in s:
		print(a * n + b * (n + 1))
		continue
	min_lower_length = 2 * a / b + 1
	start = 0
	while s[start] == 0:
		start += 1
	end = n - 1
	while s[end] == 0:
		end -= 1
	cost = (n + 2) * a + (n + 1) * b + (end - start + 2) * b
	c = 0
	for i in range(start, end + 1):
		if s[i] == 0:
			c += 1
		else:
			if c >= min_lower_length:
				cost += 2 * a - (c - 1) * b
			c = 0
	print(cost)


from math import inf
T = int(input())
for w in range(T):
	n_a_b = [int(i) for i in input().split()]
	s = list(input())
	matrix = [[inf, inf] for i in range(n_a_b[0] + 1)]
	matrix[0][0] = n_a_b[2]
	for i in range(n_a_b[0]):
		if s[i] != '0':
			matrix[i + 1][1] = min(matrix[i + 1][1], matrix[i][1] + n_a_b[1] + 2 * n_a_b[2])
		else:
			matrix[i + 1][1] = min(matrix[i][1] + n_a_b[1] + 2 * n_a_b[2], matrix[i][0] + 2 * (n_a_b[1] + n_a_b[2]))
			matrix[i + 1][0] = min(matrix[i][1] + 2 * n_a_b[1] + n_a_b[2], matrix[i][0] + n_a_b[1] + n_a_b[2])
	print(matrix[n_a_b[0]][0])


from math import *
from sys import *
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	inf = 10 ** 20 + 7
	dp = [[inf, inf] for i in range(n)]
	dp[0] = [b + a, b + a * 2]
	for i in range(1, n):
		if s[i] == '0':
			dp[i][0] = min(dp[i - 1][0] + b + a, dp[i - 1][1] + 2 * (b + a))
			dp[i][1] = min(dp[i - 1][0] + b + 2 * a, dp[i - 1][1] + 2 * b + a)
		else:
			dp[i][1] = dp[i - 1][1] + 2 * b + a
	print(dp[-1][0] + b)


s = lambda : list(map(int, input().split()))
T = int(input())
for tc in range(T):
	(n, a, b) = s()
	string = list(map(lambda x: x == '1', input()))
	cost = a * n + b * (n + 1)
	isBeginning = True
	zeros = 0
	for x in string:
		if x:
			if zeros == 0:
				cost += b
			else:
				if not isBeginning and b * (zeros - 1) < 2 * a:
					cost -= 2 * a
					cost += b * (zeros - 1)
				isBeginning = False
				zeros = 0
				cost += a + b
		else:
			if zeros == 0:
				cost += a + b
			zeros += 1
	print(cost - a - b)


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input() + '1'
	ans = n * a + (n + 1) * 2 * b
	cnt_0 = 0
	for i in range(len(s)):
		tmp = 0
		if s[i] == '0':
			cnt_0 += 1
		if s[i] == '1' and cnt_0 > 0:
			if i - cnt_0 == 0:
				tmp += 1
			if i == n:
				tmp += 1
			if tmp >= 1:
				ans += (2 - tmp) * a - (cnt_0 - 1 + tmp) * b
			elif (2 - tmp) * a - (cnt_0 - 1 + tmp) * b < 0:
				ans += (2 - tmp) * a - (cnt_0 - 1 + tmp) * b
			cnt_0 = 0
	print(ans)


t = int(input())
INF = 10 ** 16
for _ in range(t):
	(n, a, b) = map(int, input().split())
	B = input()
	A = [[INF, INF] for _ in range(n + 1)]
	A[0][0] = b
	for i in range(1, n + 1):
		if B[i - 1] == '0':
			A[i][0] = min([A[i - 1][1] + 2 * a + b, A[i - 1][0] + a + b])
			A[i][1] = min([A[i - 1][1] + a + 2 * b, A[i - 1][0] + 2 * a + 2 * b])
		else:
			A[i][1] = A[i - 1][1] + a + 2 * b
	print(A[n][0])


rw = int(input())
for wewq in range(rw):
	(n, a, b) = map(int, input().split())
	s = input()
	dp = [0] * (n + 1)
	dp[0] = b
	t2 = False
	i = 0
	c = []
	while i < n - 1:
		c.append(1)
		i += 1
		while s[i] == s[i - 1] and i < n - 1:
			c[-1] += 1
			i += 1
	if s[n - 1] == s[n - 2]:
		c[-1] += 1
	else:
		c.append(1)
	cn = len(c)
	if cn == 1:
		print(b * c[0] + a * c[0] + b)
		continue
	f = (a + b) * c[0] + a
	tr = c[0] + 1
	br = c[0]
	for i in range(1, cn - 1):
		if i % 2 == 1:
			f += b * 2 * c[i] + a * c[i]
			tr += c[i]
			br += c[i] * 2
		elif (a + b) * c[i] + 2 * a + b > (2 * b + a) * c[i]:
			f += (2 * b + a) * c[i]
			tr += c[i] + 2
			br += 2 * c[i]
		else:
			f += (a + b) * c[i] + 2 * a + b
			tr += c[i] + 2
			br += c[i] + 1
	f += a + (a + b) * c[-1] + 2 * b
	tr += 1 + c[-1]
	br += 2 + c[-1]
	print(f)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	next1 = [float('inf')] * (n + 1)
	j = float('inf')
	for i in range(n - 1, -1, -1):
		next1[i] = j
		if s[i] == '1':
			j = i
	ans = a * n + b * (n + 1)
	i = 0
	flag = 0
	while i < n:
		if s[i] == '1':
			if flag == 0:
				ans += a
			ans += b
			ans += min((next1[i] - i - 1) * b, 2 * a + b)
			flag = 1
			i = next1[i]
		else:
			i += 1
	if flag == 1:
		ans -= a
	print(ans)


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	res = 0
	i = 0
	if n == 2:
		print(3 * b + 2 * a)
		continue
	if s == '0' * n:
		print((n + 1) * b + n * a)
		continue
	while i < len(s):
		if s[i] == '0':
			if s[i + 1] == '0':
				res += b + a
			else:
				res += 2 * a + b
			i += 1
		elif s[i + 1] == '1':
			res += 2 * b + a
			i += 1
		else:
			res += 2 * b + a
			for j in range(i + 1, len(s)):
				if s[j] == '1':
					if j - i > 2:
						if 2 * a < (j - i - 2) * b:
							res += 2 * a + (j - i - 1) * a + (j - i) * b
						else:
							res += (j - i - 1) * a + 2 * (j - i - 1) * b
						i = j
						break
					else:
						res += 2 * b + a
						i = j
						break
			else:
				res += (len(s) - i) * (a + b) + b
				break
	print(res)


t = int(input())
for i2 in range(t):
	(n, a, b) = map(int, input().split())
	s = str(input())
	dp = [[0] * 2 for i in range(n)]
	maxn = 123456789876543212345678
	for i in range(n):
		if i == 0:
			(dp[0][0], dp[0][1]) = (a + b, maxn)
		elif s[i] == '0':
			dp[i][0] = min(dp[i - 1][0], dp[i - 1][1] + a + b) + a + b
			dp[i][1] = min(dp[i - 1][0] + a, dp[i - 1][1]) + a + b * 2
		else:
			dp[i][0] = maxn
			dp[i][1] = min(dp[i - 1][0] + a, dp[i - 1][1]) + a + b * 2
	print(dp[n - 1][0] + b)


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	cnt = 0
	first_one = 0
	last_one = 0
	first_zero = 0
	last_zero = 0
	diff = 0
	for i in range(n):
		if s[i] == '1':
			if first_one == 0:
				first_one = i
			last_one = i
			if a * 2 < b * (last_zero - first_zero):
				diff += a * 2 - b * (last_zero - first_zero)
			first_zero = 0
			last_zero = 0
		if s[i] == '0':
			if first_one != 0:
				if first_zero == 0:
					first_zero = i
				last_zero = i
	if first_one == 0:
		ans = a * n + b * (n + 1)
	else:
		ans = a * (n + 2) + b * (n + 1 + (last_one - first_one + 2)) + diff
	print(ans)


for _ in range(int(input())):
	(n, a, b) = (int(s) for s in input().split())
	s = input().strip()
	ans = (n + 1) * b + n * a
	s1 = [i for i in s.split('0') if i != '']
	s2 = [i for i in s.split('1') if i != '']
	for i in range(len(s1)):
		if i == 0:
			ans += a
		if i == len(s1) - 1:
			ans += a
		ans += (len(s1[i]) + 1) * b
	for j in range(1, len(s2) - 1):
		if len(s2[j]) > 1:
			ans += min((len(s2[j]) - 1) * b, 2 * a)
	print(ans)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	c = list(map(int, list(input())))
	r = []
	l = 1
	for i in range(1, n):
		if c[i] == c[i - 1]:
			l += 1
		else:
			r.append([l, c[i - 1]])
			l = 1
	r.append([l, c[-1]])
	l = 0
	ans = n * a + (n + 1) * b
	for i in range(len(r)):
		if r[i][1] > l:
			ans += b * (r[i][0] + 1)
			ans += a
			l = 1
		elif l > r[i][1] and i != len(r) - 1:
			if 2 * a < (r[i][0] - 1) * b:
				ans += a
				l = 0
			else:
				ans += (r[i][0] - 1) * b
		elif l > r[i][1] and i == len(r) - 1:
			ans += a
		elif l == 1:
			ans += (r[i][0] + 1) * b
	print(ans)


from sys import stdin

def ler():
	for line in stdin:
		yield line.rstrip()

def converte(string):
	res = []
	anterior = '0'
	q = 0
	for s in string:
		if anterior == s:
			q += 1
		else:
			res.append(q)
			q = 1
			anterior = s
	res.append(q)
	return res

def solve(s):
	(n, cano, pilar) = [int(x) for x in next(s).split(' ')]
	custo_subida = 2 * cano + 2 * pilar
	custo_descida = 2 * cano + pilar
	custo_alto = cano + 2 * pilar
	custo_baixo = cano + pilar
	string = next(s)
	contagem = converte(string)
	if len(contagem) == 1:
		return custo_baixo * contagem[0] + pilar
	custo = pilar + custo_subida + custo_baixo * (contagem.pop(0) - 1)
	custo += custo_descida + custo_baixo * (contagem.pop() - 1)
	while contagem:
		alto = contagem.pop()
		custo += custo_alto * alto
		if not contagem:
			break
		baixo = contagem.pop()
		if baixo == 1:
			custo += custo_alto
			continue
		se_descer = custo_descida + custo_subida + custo_baixo * (baixo - 2)
		se_ficar = custo_alto * baixo
		custo += min(se_ficar, se_descer)
	return custo
s = ler()
T = int(next(s))
for i in range(T):
	print(solve(s))


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if '1' not in s:
		print((n + 1) * b + a * n)
	else:
		cg = 0
		for i in range(len(s) - 1):
			if s[i] == '1' and s[i - 1] == '0':
				cg += 1
			if s[i] == '1':
				cg += 1
		ans = (n + 1) * b + n * a + cg * b
		c = 0
		D = []
		F = 1
		for i in s:
			if i == '0':
				c += 1
			elif F:
				ans += max(0, a)
				c = 0
				F = 0
			else:
				ans += max(0, min(2 * a, (c - 1) * b))
				c = 0
		ans += max(0, a)
		print(ans)


t = int(input())

def solve():
	(n, a, b) = map(int, input().split())
	dp = [[10 ** 20, 10 ** 20] for i in range(n + 1)]
	dp[0][0] = b
	s = input()
	s += '0'
	for i in range(1, n + 1):
		if s[i] == '1':
			dp[i][1] = min(dp[i - 1][0] + 2 * a + 2 * b, dp[i - 1][1] + a + 2 * b)
		elif s[i - 1] != '1':
			dp[i][0] = min(dp[i - 1][0] + a + b, dp[i - 1][1] + 2 * a + b)
			dp[i][1] = min(dp[i - 1][0] + 2 * a + 2 * b, dp[i - 1][1] + a + 2 * b)
		else:
			dp[i][1] = dp[i - 1][1] + a + 2 * b
	print(dp[n][0])
for i in range(t):
	solve()


from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, groupby
import sys
import bisect
import string
sys.setrecursionlimit(10 ** 6)

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

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

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

def LI():
	return [int(i) for i in input().split()]
YN = ['Yes', 'No']
mo = 10 ** 9 + 7

def solve():
	(n, a, b) = MI()
	ps = '0' + input() + '0'
	s = [1 if int(ps[i:i + 2]) > 0 else 0 for i in range(len(ps) - 1)]
	ans = a + 2 * b
	ans = -a
	g = groupby(s)
	ls = [(int(i), len(list(j))) for (i, j) in g]
	nl = len(ls)
	for i in range(nl):
		h = ls[i][0]
		x = ls[i][1]
		if nl == 1:
			ans += x * (a + b)
			break
		if i == 0 or i == nl - 1:
			d = (a + b + (b if h == 1 else 0)) * x + a + (a if h == 1 else 0)
			t = 'hashikko'
		elif h == 1:
			d = (a + 2 * b) * x
			t = '2f'
		elif h == 0 and i != 0 and (i != nl - 1) and (x * b < 2 * a):
			d = (a + 2 * b) * x
			t = '2f sagenai'
		else:
			d = 2 * a + x * (a + b)
			t = '1f'
		ans += d
	print(ans)
t = I()
for _ in range(t):
	solve()


t = int(input())
while t != 0:
	(n, a, b) = map(int, input().split())
	pipe = a
	pillar = b
	s = input()
	dp = [[float('inf') for i in range(n + 2)] for j in range(2)]
	dp[0][0] = pillar
	for i in range(n):
		if s[i] == '1':
			dp[0][i + 1] = float('inf')
			dp[1][i + 1] = dp[1][i] + 2 * pillar + pipe
		else:
			dp[0][i + 1] = min(dp[0][i] + pillar + pipe, dp[1][i] + 2 * pipe + pillar)
			dp[1][i + 1] = min(dp[0][i] + 2 * pillar + 2 * pipe, dp[1][i] + 2 * pillar + pipe)
	print(dp[0][n])
	t -= 1


t = int(input())
for query in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	A = list()
	ln = 1
	j = 1
	while j < n:
		if s[j] == s[j - 1]:
			ln += 1
		else:
			A.append(ln)
			ln = 1
		j += 1
	A.append(ln)
	if len(A) == 1:
		print(a * n + b * n + b)
	else:
		ans = A[0] * b + n * a
		i = 1
		while i + 1 < len(A):
			if i % 2 == 1:
				ans += (A[i] + 1) * 2 * b + a
			else:
				ans += (A[i] - 1) * b + min(a, (A[i] - 1) * b - a)
			i += 1
		ans += A[-1] * b + a
		print(ans)


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
from itertools import groupby
t = rint()
for _ in range(t):
	(n, a, b) = rints()
	s = input()
	cost = n * a + (n + 1) * b
	for i in range(n + 1):
		left1 = i > 0 and s[i - 1] == '1'
		right1 = i < n and s[i] == '1'
		if left1 or right1:
			cost += b
		if 0 < i < n and left1 != right1:
			cost += a
	g = [sum((1 for _ in v)) for (k, v) in groupby(s) if k == '0']
	for (i, gs) in enumerate(g[1:-1]):
		if (gs - 1) * b < 2 * a:
			cost += (gs - 1) * b - 2 * a
	print(cost)


t = int(input())
for _ in range(t):
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	ones = []
	for i in range(len(s)):
		if s[i] == '1':
			ones.append(i)
	if len(ones) == 0:
		cost = n * a + (n + 1) * b
		print(cost)
		continue
	cost = (ones[0] + 1) * a + (ones[0] + 2) * b
	for i in range(1, len(ones)):
		if ones[i - 1] + 1 == ones[i]:
			cost += a + b + b
		elif ones[i - 1] + 2 == ones[i]:
			cost += 2 * (a + b + b)
		else:
			z = ones[i] - ones[i - 1] - 1
			x = (z + 1) * (a + b + b)
			y = a + b + b + (2 + z) * a + (z + 1) * b
			cost += min(x, y)
	z = n - ones[-1] - 1
	cost += (z + 2) * (a + b)
	print(cost)


def next_int():
	return int(input())

def next_int_arr():
	return map(int, input().split())
INF = 1 << 60
for _ in range(next_int()):
	(n, a, b) = next_int_arr()
	s = input()
	(dp0, dp1) = (b, INF)
	for ch in s:
		if ch == '1':
			(dp0, dp1) = (INF, dp1 + 2 * b)
		else:
			(dp0, dp1) = (min(dp0, dp1 + a) + b, min(dp1, dp0 + a) + 2 * b)
	print(dp0 + a * n)


def solve(s, n, a, b):
	cost = a * n
	cost += b * (n + 1)
	dp = []
	curr = s[0]
	count = 0
	for i in s:
		if i == curr:
			count += 1
		else:
			dp.append((curr, count))
			curr = i
			count = 1
	dp.append((curr, count))
	for i in range(1, len(dp) - 1):
		if dp[i][0] == '0' and dp[i - 1][0] == '1' and (dp[i + 1][0] == '1'):
			cost += min(2 * a, b * (dp[i][1] - 1))
	for i in dp:
		if i[0] == '1':
			cost += b * (1 + i[1])
	if len(dp) >= 3:
		cost += 2 * a
	print(cost)

def main():
	t = int(input())
	for i in range(t):
		(n, a, b) = map(int, input().split())
		s = input()
		solve(s, n, a, b)
main()


t = int(input())
for i in range(t):
	(n, x, y) = map(int, input().split())
	a = input()
	if a == '0' * n:
		print((n + 1) * y + n * x)
	else:
		r1 = 0
		r2 = 0
		s = 1
		b = []
		S = 0
		k = 0
		for i in range(1, n):
			if a[i] != a[i - 1]:
				b.append(s)
				s = 1
			else:
				s += 1
			if a[i] == '0':
				k += 1
		b.append(s)
		s = 0
		for i in range(1, len(b)):
			if i % 2 == 1:
				S += b[i] * x + (b[i] + 1) * y * 2
		for i in range(0, len(b)):
			if i % 2 == 0:
				if i == 0 or i == len(b) - 1:
					S += b[i] * y + b[i] * x + x
				else:
					f1 = b[i] * x + (b[i] - 1) * 2 * y
					f2 = (b[i] + 2) * x + (b[i] - 1) * y
					S += min(f1, f2)
		print(S)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	first_1 = s.find('1')
	last_1 = s.rfind('1')
	cost = n * a + (n + 1) * b
	if first_1 > -1:
		cost += 2 * a
		cost += (last_1 - first_1 + 2) * b
		groups = []
		cur = ''
		for c in s[first_1:last_1 + 1]:
			if c == '0':
				cur += c
			else:
				groups.append(cur)
				cur = ''
		for group in groups:
			if len(group) < 2:
				continue
			new_cost = 2 * a - (len(group) - 1) * b
			if new_cost < 0:
				cost += new_cost
	print(cost)


inf = 10 ** 18
t = int(input())
for q in range(t):
	(n, a, b) = map(int, input().split())
	path = input()
	dp = [[inf, inf] for i in range(n + 1)]
	dp[0][0] = b
	for i in range(0, n):
		if path[i] == '0':
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + a + b)
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + 2 * (a + b))
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a + 2 * b)
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 2 * a + b)
		else:
			dp[i + 1][1] = dp[i][1] + a + 2 * b
	print(dp[n][0])


from sys import stdin, stdout
from math import gcd, sqrt, inf
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = inf
for _ in range(I()):
	(n, x, y) = R()
	(*a,) = map(int, S())
	sm = y
	v = []
	lst = 0
	one = zero = 0
	for i in range(n):
		if lst == a[i] == 0:
			sm += y
		else:
			sm += 2 * y
		if lst != a[i]:
			sm += 2 * x
		else:
			sm += x
		if zero and a[i] == 1:
			v += (i - one - 1,)
			zero = 0
		if a[i] == 1:
			one = i
		if one and a[i] == 0:
			zero = 1
		lst = a[i]
	for i in v:
		sm -= max(0, (i + 2) * x + (i - 1) * y - (i * x + (i - 1) * y * 2))
	print(sm)


for i in range(int(input())):
	(n, a, b) = input().split(' ')
	n = int(n)
	a = int(a)
	b = int(b)
	patterns = list(input())
	groups = []
	bit = '0'
	count = 0
	for i in patterns:
		if i == bit:
			count += 1
		else:
			groups.append(count)
			count = 1
			bit = i
	groups.append(count)
	if len(groups) == 1:
		print(n * a + (n + 1) * b)
	else:
		zeros = groups[0::2]
		ones = groups[1::2]
		cost = (zeros[0] + zeros[-1] + 2) * (a + b)
		cost += sum(ones) * (2 * b + a)
		for i in range(1, len(zeros) - 1):
			cost1 = zeros[i] * (a + 2 * b)
			cost2 = zeros[i] * (a + b) + 2 * a + b
			if cost1 < cost2:
				cost += cost1
			else:
				cost += cost2
		print(cost)


def main():
	import sys
	input = sys.stdin.readline

	def solve():
		(n, a, b) = map(int, input().split())
		s = input()
		arr = [0] * (n + 1)
		for i in range(1, n):
			if s[i] == '1' or s[i - 1] == '1':
				arr[i] = 1
		cnts = []
		cnt = 1
		for i in range(1, n + 1):
			if arr[i] != arr[i - 1]:
				cnts.append(cnt)
				cnt = 1
			else:
				cnt += 1
		cnts.append(cnt)
		l = len(cnts)
		cost = n * a + (l - 1) * a + (n + 1) * b + sum(cnts[1:l:2]) * b
		for i in range(2, l - 2, 2):
			now = 2 * a + cnts[i] * b
			new = cnts[i] * 2 * b
			if new < now:
				cost += new - now
		print(cost)
	for _ in range(int(input())):
		solve()
	return 0
main()


t = int(input())
for nt in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	group = []
	current = '0'
	count = 0
	for i in range(n):
		if s[i] == current:
			count += 1
		else:
			group.append(count)
			count = 1
			if current == '0':
				current = '1'
			else:
				current = '0'
	if current == '0':
		group.append(count)
	cost = 0
	if len(group) != 1:
		cost += (group[0] + 1) * a + group[0] * b
		for i in range(1, len(group) - 1):
			if i % 2 == 1:
				cost += group[i] * a + group[i] * b * 2
			else:
				cost += min((group[i] + 2) * a + (group[i] + 1) * b, group[i] * a + group[i] * b * 2)
		cost += (group[-1] + 2) * b + (group[-1] + 1) * a
		print(cost)
	else:
		print(n * a + (n + 1) * b)


import sys

def solve(A, n, a, b):
	cost = n * a + (n + 1) * b
	num_ones = 0
	groups_ones = 0
	groups_zeros = [0]
	on_zeros = True
	for i in A:
		if i == 0:
			if on_zeros:
				groups_zeros[-1] += 1
			else:
				on_zeros = True
				groups_zeros.append(1)
		else:
			if on_zeros:
				on_zeros = False
				groups_ones += 1
			num_ones += 1
	cost += (groups_ones + num_ones) * b
	for i in range(1, len(groups_zeros) - 1):
		z = groups_zeros[i]
		cost += min(2 * a, (z - 1) * b)
	if num_ones > 0:
		cost += 2 * a
	return cost
in_file = sys.stdin
t = int(in_file.readline().strip())
for _ in range(t):
	(n, a, b) = map(int, in_file.readline().strip().split())
	A = list(map(int, in_file.readline().strip()))
	sys.stdout.write(str(solve(A, n, a, b)) + '\n')
sys.stdout.flush()


t = int(input())
for _ in range(t):
	(n, a, b) = (int(x) for x in input().split())
	s = input()
	cost = n * (a + b) + b
	count = 0
	i = s.find('1')
	while 0 <= i < n:
		j = i
		while j < n - 1 and s[j + 1] == '1':
			j += 1
		ones = j - i + 1
		cost += (ones + 1) * b
		i = s.find('1', j + 1)
		if i == -1:
			cost += 2 * a
			break
		zeros = i - j - 1
		cost += min((zeros - 1) * b, 2 * a)
	print(cost)


import sys
T = int(sys.stdin.readline())
for t in range(T):
	(n, a, b) = list(map(int, sys.stdin.readline().split()))
	road = sys.stdin.readline().rstrip()
	intersection = road.count('1')
	if intersection > 1:
		base = a * (n + 2) + (n + 1) * b
		plus = 0
		begin = road.index('1')
		zerocount = 0
		onecount = 0
		for i in range(begin, n):
			if road[i] == '0':
				zerocount += 1
				if onecount != 0:
					plus += (onecount + 1) * b
					onecount = 0
			else:
				onecount += 1
				if zerocount != 0:
					plus += min((zerocount - 1) * b, 2 * a)
					zerocount = 0
		print(base + plus)
	else:
		answer = a * (n + 2 * intersection) + b * (n + 1 + 2 * intersection)
		print(answer)


test = int(input())
for _ in range(test):
	(n, a, b) = map(int, input().split())
	s = input()
	ans = a * n + b * (n + 1)
	for i in range(n):
		if s[n - i - 1] == '1':
			s = s[:n - i]
			break
	for i in range(len(s)):
		if s[i] == '1':
			s = s[i:]
			break
	if s.count('1') == 0:
		print(ans)
		continue
	dp = []
	c = 1
	for i in range(len(s) - 1):
		if s[i + 1] == s[i]:
			c += 1
		else:
			dp.append(c)
			c = 1
	dp.append(c)
	for i in dp[::2]:
		ans += (i + 1) * b
	ans += len(dp[::2]) * a * 2
	for i in dp[1::2]:
		if (i - 1) * b < 2 * a:
			ans += (i - 1) * b
			ans -= 2 * a
	print(ans)


import math
T = int(input())
for _ in range(0, T):
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	low = list([b])
	high = list([math.inf])
	for num in s:
		l = low.pop()
		h = high.pop()
		if num == '0':
			low.append(min(a + b + l, a * 2 + b + h))
			high.append(min((a + b) * 2 + l, a + b * 2 + h))
		else:
			low.append(math.inf)
			high.append(a + b * 2 + h)
	print(low.pop())


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	l = input()
	x = 0
	y = a + b
	for i in range(1, n):
		if l[i] == '1':
			x = 10000000000000000
		c = x
		if l[i] == '0':
			x = min(x + a + b, y + 2 * a + b)
		y = min(c + 2 * a + 2 * b, y + a + 2 * b)
	print(x + a + 2 * b)


import math
x = int(input())
for i in range(x):
	(n, a, b) = map(int, input().split())
	s = input()
	dp = [[0 for i in range(len(s))] for i in range(2)]
	dp[0][0] = b
	dp[1][0] = math.inf
	dp[1][-1] = math.inf
	for i in range(1, len(s)):
		if s[i] == '1' or s[i - 1] == '1':
			dp[0][i] = math.inf
			dp[1][i] = min(dp[0][i - 1] + a + a + b + b, dp[1][i - 1] + a + b + b)
		else:
			dp[0][i] = min(dp[1][i - 1] + a + a + b, dp[0][i - 1] + a + b)
			dp[1][i] = min(dp[0][i - 1] + a + a + b + b, dp[1][i - 1] + a + b + b)
	print(min(dp[1][-1] + a + a + b, dp[0][-1] + a + b))


import math
nq = int(input())

def beg_cost(x, pipe, pill):
	return pipe - x * pill

def cost(x, pipe, pill):
	return 2 * pipe - (x - 1) * pill
for i in range(nq):
	costs = input().split()
	n = int(costs[0])
	pipe = int(costs[1])
	pill = int(costs[2])
	mincost = (n + 1) * 2 * pill + n * pipe
	seq = input()
	allzeros = 0
	curr = 0
	count = 0
	ls = []
	for i in range(len(seq) - 1):
		if seq[i] != seq[i + 1]:
			ls.append(i + 1)
	ls.append(len(seq))
	if len(ls) == 1:
		allzeros = 1
	else:
		cst = beg_cost(ls[0], pipe, pill)
		mincost += cst
		if len(ls) > 1:
			for i in range(1, len(ls)):
				if i % 2 == 0 and i != len(ls) - 1:
					cst = cost(ls[i] - ls[i - 1], pipe, pill)
					if cst < 0:
						mincost += cst
				elif i % 2 == 0:
					cst = beg_cost(ls[i] - ls[i - 1], pipe, pill)
					mincost += cst
	if allzeros == 1:
		print((n + 1) * pill + n * pipe)
	else:
		print(mincost)


t = int(input())
for it in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	dp = [[int(1e+18)] * 2 for i in range(n + 1)]
	dp[0][0] = b
	for i in range(n):
		if s[i] == '1':
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a + 2 * b)
		else:
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + a + b)
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + 2 * (a + b))
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a + 2 * b)
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 2 * a + b)
	print(dp[n][0])


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	(n, a, b) = stdin.readline().strip().split(' ')
	(n, a, b) = (int(n), int(a), int(b))
	s = stdin.readline().strip()
	h1 = a + b
	h2 = 2 * a + b
	for i in range(1, len(s)):
		if s[i] == '0':
			if h1 == None:
				h1 = h2 + 2 * b + 2 * a
				h2 = h2 + 2 * b + a
			else:
				t1 = min(h1 + a + b, h2 + 2 * a + 2 * b)
				h2 = min(h2 + 2 * b + a, h1 + b + 2 * a)
				h1 = t1
		else:
			h2 = h2 + 2 * b + a
			h1 = None
	ans = h1 + b
	stdout.write(str(ans) + '\n')


from itertools import groupby
total = int(input())
for i in range(total):
	(n, a, b) = [int(x) for x in input().split()]
	road = input()
	sroad = [''.join(group) for (key, group) in groupby(road)]
	l = len(sroad)
	if l == 1:
		print(n * a + (n + 1) * b)
	else:
		cnt = 0
		total_cost = 0
		for chunk in sroad:
			lc = len(chunk)
			if '0' in chunk:
				if cnt == 0:
					total_cost += lc * b + (lc + 1) * a
				elif cnt == l - 1:
					total_cost += (lc + 2) * b + (lc + 1) * a
				else:
					total_cost += min(a * lc + 2 * b * lc, (lc + 2) * a + b * (lc + 1))
			else:
				total_cost += 2 * b * lc + a * lc
			cnt += 1
		print(total_cost)


t = int(input())
for z in range(t):
	(n, a, b) = map(int, input().split())
	arr = list(map(int, list(input())))
	if not 1 in arr:
		print((n + 1) * b + n * a)
		continue
	dst = 0
	need = (2 * a + b - 1) // b
	s = 0
	first = arr.index(1)
	s = first * (a + b) + a + 2 * b + a
	for i in range(first + 1, n):
		if arr[i] == 1:
			if dst == 0:
				s += 2 * b + a
			else:
				s += min((dst - 1) * (a + b) + 4 * (a + b), (dst - 1) * (a + 2 * b) + 4 * b + 2 * a)
			dst = 0
		else:
			dst += 1
	s += dst * (a + b) + 2 * (a + b) - a
	print(s)


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

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 time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

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

def solve():
	(N, a, b) = getInts()
	S = [int(s) for s in input()]
	num1s = sum(S)
	intervals = []
	curr = 0
	curr_val = 0
	for j in range(N):
		if S[j] == curr_val:
			curr += 1
		else:
			if not curr_val:
				intervals.append(curr)
			curr = 1
			curr_val ^= 1
	intervals.append(curr)
	if len(intervals) == 1:
		return N * a + (N + 1) * b
	ans = (N + 2) * a + (N + 1) * b
	for j in range(1, N):
		if S[j - 1] or S[j]:
			ans += b
	intervals.pop(0)
	intervals.pop()
	while intervals:
		x = intervals.pop()
		ans += min((x - 1) * b, 2 * a)
	return ans
for _ in range(getInt()):
	print(solve())


for t in range(int(input())):
	(n, a, b) = list(map(int, input().split()))
	s = [c for c in input()]
	bridge = 0
	raised = False
	for (i, c) in enumerate(s):
		if c == '1' and (not raised):
			raised = True
		elif c == '0' and raised:
			bridge += 1
		elif c == '1' and raised:
			if (bridge - 1) * b < 2 * a:
				for j in range(i - bridge, i):
					s[j] = '1'
			bridge = 0
	lengths = []
	length = 0
	for c in s:
		if c == '1':
			length += 1
		elif length > 0:
			lengths.append(length)
			length = 0
	print((n + 2 * len(lengths)) * a + (n + 1 + len(lengths) + sum(lengths)) * b)


import os
import sys
import math
from io import BytesIO, IOBase
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
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 SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: 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 SegmentTree1:

	def __init__(self, data, default=10 ** 6, 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)
MOD = 10 ** 9 + 7

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
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10)]
pp = [0] * 10

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

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

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = arr[0]
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			right = mid - 1
		else:
			res = arr[mid]
			left = mid + 1
	return res
for _ in range(int(input())):
	(n, pipes, pillars) = map(int, input().split())
	info = input()
	precalculated = [[float('inf') for i in range(2)] for j in range(n + 1)]
	precalculated[0][0] = pillars
	for position in range(n):
		current_position = position
		next_postion = position + 1
		if info[position] == '1':
			precalculated[next_postion][1] = min(precalculated[next_postion][1], precalculated[current_position][1] + pipes + 2 * pillars)
		else:
			precalculated[next_postion][1] = min(precalculated[next_postion][1], precalculated[current_position][0] + 2 * pipes + 2 * pillars)
			precalculated[next_postion][0] = min(precalculated[next_postion][0], precalculated[current_position][0] + 1 * pipes + 1 * pillars)
			precalculated[next_postion][1] = min(precalculated[next_postion][1], precalculated[current_position][1] + 1 * pipes + 2 * pillars)
			precalculated[next_postion][0] = min(precalculated[next_postion][0], precalculated[current_position][1] + 2 * pipes + 1 * pillars)
	print(precalculated[n][0])


def minCost2(n, road, a, b):
	height = 1
	cost = b
	s = -1
	for i in range(0, n):
		cost += a + b
		if i < n - 1 and (road[i] == 1 or road[i + 1] == 1):
			cost += b
			if height == 1:
				cost += a
				height = 2
			if road[i] == 1 and s != -1:
				m = i - s - 1
				if m * b < 2 * a:
					cost = cost - 2 * a + m * b
				s = -1
		elif height == 2:
			s = i
			cost += a
			height = 1
	return cost
r = int(input(''))
for i in range(0, r):
	(road_size, t_price, s_price) = [int(x) for x in str(input('')).split(' ')]
	road = [int(x) for x in str(input(''))]
	print(minCost2(road_size, road, t_price, s_price))


T = int(input())
for i in range(T):
	(n, a, b) = [int(i) for i in input().split()]
	s = [int(c) for c in input().strip('0')]
	cost = 0
	nzero = 0
	if len(s) == 0:
		cost = n * a + (n + 1) * b
	else:
		cost = (n - len(s) + 2) * (a + b)
		for e in s:
			if e == 0:
				nzero += 1
			else:
				if nzero == 0:
					cost += a + 2 * b
				elif nzero == 1:
					cost += 2 * (a + 2 * b)
				elif nzero < 2 * a / b + 1:
					cost += (nzero + 1) * (a + 2 * b)
				else:
					cost += (nzero + 3) * (a + b)
				nzero = 0
	print(cost)


Q = int(input())
for _ in range(Q):
	(n, a, b) = list(map(int, input().split()))
	s = list(map(int, input()))
	m = a * n
	m += b * (n + 1)
	if sum(s) == 0:
		print(m)
		continue
	head = s.index(1)
	for i in reversed(range(n)):
		if s[i] == 1:
			tail = i
			break
	c = a * 2 // b + 1
	i = head
	while i < tail:
		i += 1
		if s[i] == 1:
			continue
		j = i + 1
		while s[j] == 0:
			j += 1
		if j - i <= c:
			for k in range(i, j):
				s[k] = 1
		i = j
	z = 1
	for i in range(head, tail):
		if s[i + 1] - s[i] == 1:
			z += 1
	m += sum(s) * b
	m += z * 2 * a
	m += z * b
	print(m)


for t in range(int(input())):
	(n, a, b) = [int(j) for j in input().split()]
	ans = 0
	prev = -1
	last_state = 0
	l = [int(j) for j in list(input())]
	prev = 0
	p = [0 for i in range(n)]
	flag = False
	for i in range(n)[::-1]:
		if l[i] == 1 and flag:
			p[i] = prev
			prev = i
		if not flag and l[i] == 1:
			flag = True
			prev = i
			p[i] = 0
		if l[i] == 0:
			p[i] = prev
	curr_state = 0
	ans = b
	jump = False
	for i in range(n - 1):
		if jump:
			jump = False
			ans += 2 * a + b
		elif l[i + 1] == 0:
			if curr_state == 0:
				ans += a + b
			else:
				ans += a + 2 * b
				if 2 * a <= (p[i] - i - 2) * b or p[i] == 0:
					jump = True
					curr_state = 0
		elif l[i + 1] == 1:
			if curr_state == 1:
				ans += a + 2 * b
			else:
				ans += 2 * a + 2 * b
				curr_state = 1
	if curr_state == 1 or jump:
		ans += 2 * a + b
	else:
		ans += a + b
	print(ans)


import sys
T = int(sys.stdin.readline())
for t in range(0, T):
	(n, a, b) = list(map(int, sys.stdin.readline().strip().split()))
	s = sys.stdin.readline().strip()
	i = 0
	c = n * a + (n + 1) * b
	v = 0
	for j in range(0, n - 1):
		if s[j] == '1' or s[j + 1] == '1':
			c = c + b
			v = 1
	if v == 1:
		c = c + 2 * a
		while s[i] == '0':
			i = i + 1
		j = n - 1
		while s[j] == '0':
			j = j - 1
		v = 0
		while i <= j:
			if s[i] == '1':
				if v > 0:
					c = c + min([(v - 1) * b, 2 * a])
				v = 0
			if s[i] == '0':
				v = v + 1
			i = i + 1
	print(c)


x = int(input())
for i in range(x):
	(n, a, b) = map(int, input().split())
	queue = input()
	first = queue.find('1')
	if first == -1:
		print(a * n + b * (n + 1))
		continue
	backqueue = queue[::-1]
	last = n - 1 - backqueue.find('1')
	save = (2 * a - 1) // b + 2
	conseczeroes = 0
	total = (n - last + first + 1) * (a + b)
	while first <= last:
		if queue[first] == '1':
			if conseczeroes >= save:
				total += (conseczeroes + 3) * (a + b)
			else:
				total += (conseczeroes + 1) * (a + 2 * b)
			conseczeroes = 0
		else:
			conseczeroes += 1
		first += 1
	print(str(total))


from sys import stdin
input = stdin.readline
a = []
ans = []
for _ in range(int(input())):
	(n, p, q) = map(int, input().split())
	s = input()
	l = list(s)
	cnt = 0
	if s.count('1') == 0:
		print(q * (n + 1) + p * n)
		continue
	a = [0]
	b = [1]
	for i in range(1, n):
		if s[i] == s[i - 1]:
			b[-1] += 1
			continue
		else:
			a.append(int(s[i]))
			b.append(1)
	cp = 1
	ans = q
	for i in range(len(a)):
		n = b[i]
		if i == len(a) - 1:
			ans += (n + 1) * p + q * n
			break
		if a[i] == 0:
			if cp == 1:
				ans += p * (n + 1)
				ans += (n - 1) * q
				cp = 2
			else:
				ans += min((n + 2) * p + (n - 1) * q, n * p + (n - 1) * (2 * q))
				cp = 2
		else:
			ans += n * p + 2 * q * (n + 1)
	print(ans)


T = int(input())
for _ in range(T):
	nab = list(map(int, input().split()))
	(n, a, b) = (nab[0], nab[1], nab[2])
	s = str(input())
	crp = list()
	for i in range(n):
		if s[i] == '1':
			crp.append(i)
	min_cost = (n + 1) * b + n * a
	if len(crp) == 0:
		print(min_cost)
	elif len(crp) == 1:
		print(min_cost + 2 * a + 2 * b)
	else:
		min_cost += 2 * a + 2 * b
		for i in range(len(crp) - 1):
			if crp[i] == crp[i + 1] - 1:
				min_cost += b
			else:
				min_cost += min(2 * a, (crp[i + 1] - crp[i] - 2) * b)
				min_cost += 2 * b
		print(min_cost)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	s = [i for i in range(n) if s[i] == '1']
	if not s:
		print(n * a + (n + 1) * b)
		continue
	ans = (s[0] + n - s[-1] + 2) * (a + b) + b
	for i in range(len(s) - 1):
		ans += a + 2 * b
		if s[i + 1] == s[i] + 1:
			continue
		if s[i + 1] == s[i] + 2:
			ans += a + 2 * b
		else:
			x = s[i + 1] - s[i] - 1
			ans += min((x - 1) * b, 2 * a) + (x + 1) * b + x * a
	print(ans)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

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

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(inp())):
	(n, a, b) = mp()
	s = inp()
	dp = l2d(n + 1, 2)
	dp[0][0] = b
	dp[0][1] = inf
	for i in range(1, n + 1):
		if s[i - 1] == '1' or (i < n and s[i] == '1'):
			dp[i][0] = inf
			dp[i][1] = min(dp[i - 1][0] + 2 * a + 2 * b, dp[i - 1][1] + a + 2 * b)
		else:
			dp[i][0] = min(dp[i - 1][0] + a + b, dp[i - 1][1] + 2 * a + b)
			dp[i][1] = min(dp[i - 1][0] + 2 * a + 2 * b, dp[i - 1][1] + a + 2 * b)
	print(dp[n][0])


t = int(input())
for d in range(t):
	(n, a, b) = map(int, input().split())
	s = [int(p) for p in list(input())]
	c = b
	i = 0
	z = True
	while i < n:
		j = i
		if z:
			while j + 1 < n and s[j + 1] == 0:
				j += 1
			l = j - i + 1
			if l == n:
				c += l * a + l * b
				break
			elif i == 0:
				c += (l + 1) * (a + b)
			elif j == n - 1:
				c += l * (a + b) + a
			elif l == 1:
				c += a + 2 * b
			else:
				c += min(2 * a + l * a + (l - 1) * b + 2 * b, l * a + l * 2 * b)
		else:
			while j + 1 < n and s[j + 1] == 1:
				j += 1
			l = j - i + 1
			c += l * a + 2 * l * b
		i = j + 1
		z = not z
	print(c)


for i in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	i = 1
	cost = a + b + b
	prev = 0
	while i < n and s[i] == '0':
		cost += a + b
		i += 1
	while i < n - 1:
		if s[i] == '1':
			j = i
			c = 1
			while j < n and s[j] == '1':
				c += 1
				j += 1
			cost += 2 * c * b + c * a
			if prev == 0:
				cost += a
			i = j
			prev = 1
		else:
			j = i
			c = -1
			while j < n and s[j] == '0':
				c += 1
				j += 1
			if c == 0:
				i = j
				continue
			i = j
			l = c * b * 2 + c * a
			m = c * b + 2 * a + c * a
			if j == n:
				cost += c * b + c * a + a
				prev = 0
				continue
			if l <= m:
				prev = 1
				cost += l
			else:
				cost += m - a
				prev = 0
	if prev == 1:
		cost += a
	print(cost)


t = int(input())
INF = int(1e+19)
for w in range(t):
	(n, a, b) = [int(i) for i in input().split()]
	s = list(str(input()))
	dp = [[INF, INF] for i in range(n + 1)]
	dp[0][0] = b
	for i in range(n):
		if s[i] == '0':
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + a + b)
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + 2 * (a + b))
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a + 2 * b)
			dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 2 * a + b)
		else:
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + a + 2 * b)
	print(dp[n][0])


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

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

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

def solve():
	(n, a, b) = sep()
	s = list(inp())
	ans = a * n + b * (n + 1)
	if s.count('1') == 0:
		print(ans)
		return
	ind = s.index('1')
	ans += a
	while ind < n:
		i = ind + 1
		while i < n and s[i] == '0':
			i += 1
		if i == n:
			ans += 2 * b
			ans += a
			ind = i
		else:
			ans += 2 * b
			numofzeros = i - (ind + 1)
			if numofzeros == 0:
				ans -= b
				ind = i
				continue
			if numofzeros == 1:
				ind = i
				continue
			if 2 * a < (numofzeros - 1) * b:
				ans += 2 * a
			else:
				ans += (numofzeros - 1) * b
			ind = i
	print(ans)
testcase(int(inp()))


import sys, os
from math import sqrt, gcd, ceil, log, floor, sin, pi
from math import factorial as fact
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
from itertools import permutations
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 10 ** 9 + 7

def main():
	ans_ = []
	for _ in range(int(input())):
		(n, a, b) = read()
		s = input().strip()
		sm = n * a + (n + 1) * b
		arr = [len(j) for j in s.split('0') if j]
		for i in arr:
			sm += (i + 1) * b
		sm += s.count('01') * a + s.count('10') * a
		arr = [len(j) for j in s.strip('0').split('1') if j]
		for i in arr:
			(x, y) = (2 * a + b * (i - 1), 2 * b * (i - 1))
			if x > y:
				sm -= x
				sm += y
		ans_.append(sm)
	for i in ans_:
		print(i)
main()


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	road = input()
	lows = []
	i = 0
	cost = n * (a + b) + b
	while i != n and road[i] == '0':
		i += 1
	if i == n:
		print(cost)
		continue
	cost += a * 2
	while i < n:
		start = i
		while i < n and road[i] == '1':
			i += 1
		cost += (i - start + 1) * b
		if i == n:
			break
		start = i
		while i < n and road[i] == '0':
			i += 1
		if i - start - 1 != 0 and i != n:
			lows.append(i - start - 1)
	for low in lows:
		cost += min(2 * a, low * b)
	print(cost)


from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
t = int(rd())
while t:
	(n, a, b) = rrd()
	s = str(rd().strip())
	ans = (n + 1) * b + a
	for i in range(1, n):
		if s[i] == '0' and s[i - 1] == '1':
			ans += 2 * a + b
		elif s[i] == '1' and s[i - 1] == '0':
			ans += 2 * a + b
		elif s[i] == '1':
			ans += b + a
		else:
			ans += a
		if i > 2 and s[i] == '1' and (s[i - 1] == '0') and (s[i - 2] == '1'):
			ans += -2 * a
	pre = 0
	for i in range(1, n):
		if s[i] == '0' and s[i - 1] == '1':
			pre = i + 1
		if s[i] == '1' and s[i - 1] == '0':
			tot = max(0, i - pre)
			if not tot or not pre:
				continue
			mo = tot * b - 2 * a
			if mo < 0:
				ans += mo
	print(ans)
	t -= 1


n = int(input())
for i in range(n):
	raw = input().split()
	(n, a, b) = [int(x) for x in raw]
	s = input()
	x = n
	y = n + 1
	count = 0
	check_1 = []
	check_0 = []
	count_0 = 0
	status = []
	for i in range(n - 1):
		if s[i] == '1' and s[i + 1] == '1':
			count += 1
		elif s[i] == '1' and s[i + 1] == '0':
			count += 1
			check_1.append(count)
			count = 0
			status.append(i + 1)
		elif s[i] == '0' and s[i + 1] == '0':
			count_0 += 1
		else:
			count_0 += 1
			check_0.append(count_0)
			count_0 = 0
			status.append(i + 1)
	ev = 2 * a / b
	bilist = []
	for i in range(len(s)):
		bilist.append(s[i])
	for i in range(len(status) // 2 - 1):
		if status[2 * (i + 1)] - status[2 * i + 1] - 1 < ev:
			bilist[status[2 * i + 1]:status[2 * (i + 1)]] = ['1'] * (-status[2 * i + 1] + status[2 * (i + 1)])
	x = n
	y = n + 1
	count = 0
	for i in range(n - 1):
		if bilist[i] == '1' and bilist[i + 1] == '1':
			count += 1
		if bilist[i] == '1' and bilist[i + 1] == '0':
			count += 1
			x += 2
			y += count + 1
			count = 0
	print(str(x * a + y * b))


t = int(input())
for each1 in range(t):
	data_list = input().split(' ')
	n = int(data_list[0])
	a = int(data_list[1])
	b = int(data_list[2])
	ss = input()
	ans = 0
	l = 0
	r = 0
	ss_len = len(ss)
	i = 0
	while i < ss_len:
		l = i
		while i < ss_len and ss[i] == '0':
			i = i + 1
		r = i
		if r == ss_len:
			r = r
		p = r - l
		if r != ss_len and l != 0:
			if (p - 1) * b + (p + 2) * a > (p - 1) * 2 * b + p * a:
				ans = ans + (p - 1) * 2 * b + p * a
			else:
				ans = ans + (p - 1) * b + (p + 2) * a
		elif l == 0 and r == ss_len:
			ans = ans + p * a + (p + 1) * b
		else:
			ans = ans + p * b + (p + 1) * a
		l = i
		while i < ss_len and ss[i] == '1':
			i = i + 1
		r = i
		p = r - l
		if r < ss_len:
			ans = ans + p * a + (p + 1) * 2 * b
	print(ans)


t = int(input())
vsp = []
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	ind_of_1 = []
	for i in range(n):
		if s[i] == '1':
			ind_of_1.append(i)
	m = len(ind_of_1)
	j = -1
	count = b
	h = 1
	hs = []
	for i in range(n - 1):
		if s[i] == '0' and s[i - 1] == '1':
			if j == m - 1:
				count += 2 * a + b
				h = 1
			elif 4 * a + b + (ind_of_1[j + 1] - ind_of_1[j] - 3) * (a + b) < (ind_of_1[j + 1] - ind_of_1[j] - 1) * a + (ind_of_1[j + 1] - ind_of_1[j] - 2) * 2 * b:
				h = 1
				count += 2 * a + b
			else:
				count += a + 2 * b
		elif s[i] == '0' and s[i + 1] == '1' and (h == 1):
			count += 2 * a + 2 * b
			h = 2
		elif s[i] == '0' and s[i + 1] == '1' and (h == 2):
			count += a + 2 * b
		elif s[i] == '0' and s[i + 1] == '0' and (h == 1):
			count += a + b
		elif s[i] == '0' and s[i - 1] == '0' and (h == 2):
			count += a + 2 * b
		elif s[i] == '1':
			count += a + 2 * b
			j += 1
		hs.append(h)
	if h == 2:
		count += 2 * a + b
	else:
		count += a + b
	print(count)


t = int(input())
while t:
	t -= 1
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	l = -1
	r = -1
	for i in range(len(s)):
		if s[i] == '1':
			l = i
			break
	if l != -1:
		for i in range(len(s) - 1, -1, -1):
			if s[i] == '1':
				r = i
				break
	c = n * a + (n + 1) * b
	if l == -1:
		print(c)
	else:
		ch0 = 0
		ch1 = 0
		nzero = 0
		for i in range(l, r + 2):
			if s[i] == '0':
				ch0 = 1
				if ch1 == 1:
					c += b
				ch1 = 0
				nzero += 1
			else:
				ch1 = 1
				if ch0 == 1:
					if (nzero - 1) * b < 2 * a:
						c += (nzero - 1) * b
					else:
						c += 2 * a
				ch0 = 0
				nzero = 0
				c += b
		print(c + 2 * a)


for rpt in range(int(input())):
	(roadlength, pipecost, pillarcost) = [int(x) for x in input().split(' ')]
	crossroads = input()
	res = (roadlength + 1) * pillarcost
	segments = []
	current = '0'
	currentlength = 1
	for i in range(1, roadlength):
		if crossroads[i] == current:
			currentlength += 1
		else:
			segments.append(currentlength)
			current = crossroads[i]
			currentlength = 1
	segments.append(currentlength)
	if len(segments) > 1:
		res += (segments[0] + 1) * pipecost
		current = 1
		for i in range(1, len(segments) - 1):
			if current == 1:
				res += segments[i] * pipecost + segments[i] * pillarcost
				current = 0
			else:
				if 2 * pipecost >= pillarcost * (segments[i] - 1):
					res += segments[i] * pipecost + segments[i] * pillarcost
				else:
					res += pillarcost + 2 * pipecost + segments[i] * pipecost
				current = 1
		res += segments[-1] * pipecost + pipecost
		print(res + pillarcost)
	else:
		print(res + segments[0] * pipecost)


q = int(input().strip())
for i in range(q):
	(n, a, b) = [int(x) for x in input().strip().split()]
	r = [int(x) for x in input().strip()]
	i = 0
	r2 = []
	while i < n:
		if r[i] == 0:
			r2.append([0, 0])
			while i < n and r[i] == 0:
				r2[-1][1] += 1
				i += 1
		else:
			r2.append([1, 0])
			while i < n and r[i] == 1:
				r2[-1][1] += 1
				i += 1
	d = True
	c = 0
	res = ''
	for par in range(1, len(r2) - 1):
		if r2[par][0] == 0:
			if 2 * a > (r2[par][1] - 1) * b or r2[par][1] < 2:
				res += '1' * r2[par][1]
			else:
				res += '+'
				res += max(r2[par][1] - 2, 0) * '0'
				res += '-'
		else:
			res += '1' * r2[par][1]
	if len(r2) <= 1:
		res = '0' * r2[0][1]
	else:
		res = max(0, r2[0][1] - 1) * '0' + '+' + res
		res += '-' + max(0, r2[-1][1] - 1) * '0'
	c = b
	for ch in res:
		if ch == '0':
			c += a + b
		elif ch == '1':
			c += a + 2 * b
		elif ch == '+':
			c += 2 * (a + b)
		elif ch == '-':
			c += 2 * a + b
	print(c)


x = int(input())
Ans = []
for i in range(x):
	(n, a, b) = map(int, input().split())
	s = input()
	index_of_ferst = -1
	for j in range(len(s)):
		if s[j] == '1' and index_of_ferst == -1:
			index_of_ferst = j
	index_of_end = -1
	for j in range(len(s) - 1, -1, -1):
		if s[j] == '1' and index_of_end == -1:
			index_of_end = j
	if index_of_ferst != -1:
		S = s[index_of_ferst:index_of_end + 1]
		z = (n + 2) * a + (n + 1) * b + (index_of_end - index_of_ferst + 2) * b
		K = []
		ox = 0
		for j in range(len(S)):
			if S[j] == '0':
				ox += 1
			elif ox != 0:
				K.append(ox)
				ox = 0
		for k in K:
			if b * (k - 1) > 2 * a:
				z -= b * (k - 1) - 2 * a
		Ans.append(z)
	else:
		Ans.append(n * a + (n + 1) * b)
for ans in Ans:
	print(ans)


t = int(input())
for kek in range(t):
	(n, a, b) = list(map(int, input().split()))
	s = list(map(int, input()))
	h = list()
	j = 0
	ans = 0
	while j < len(s) and int(s[j]) != 1:
		j += 1
	if j == len(s):
		ans = n * a + b * (n + 1)
	else:
		i = j
		for j in range(len(s) - 1):
			if s[j] == 1 and s[j + 1] == 0:
				h.append([i + 1, j + 1])
			elif s[j] == 0 and s[j + 1] == 1:
				i = j
		ans += (h[0][0] + 1) * a + h[0][0] * b
		ans += (n - h[-1][1] + 1) * a + (n - h[-1][1]) * b
		for j in h:
			ans += (j[1] - j[0]) * a
			ans += (j[1] - j[0] + 1) * 2 * b
		for j in range(len(h) - 1):
			x = h[j + 1][0] - h[j][1]
			poverh = 2 * b * (x - 1) + x * a
			poniz = b * (x - 1) + (x + 2) * a
			ans += min(poverh, poniz)
	print(ans)


import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10 ** 9 + 7
inf = float('inf')

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

def LI():
	return list(map(int, sys.stdin.readline().split()))
t = I()
for _ in range(t):
	(n, a, b) = LI()
	s = input()
	dp = [[inf] * (n + 1) for _ in range(2)]
	s += '0'
	dp[0][0] = b
	for i in range(n):
		if s[i] == '0' and s[i + 1] == '0':
			dp[0][i + 1] = min(dp[0][i + 1], dp[0][i] + a + b, dp[1][i] + 2 * a + b)
			dp[1][i + 1] = min(dp[1][i + 1], dp[0][i] + a * 2 + b * 2, dp[1][i] + a + 2 * b)
		else:
			dp[1][i + 1] = min(dp[1][i + 1], dp[0][i] + a * 2 + b * 2, dp[1][i] + a + 2 * b)
	print(dp[0][n])


t = int(input())
for _ in range(t):
	(n, a, b) = (int(i) for i in input().split())
	s = input()
	price = n * (a + b) + b
	i = 0
	upped = False
	while i < n:
		cur = s[i]
		if cur == '1':
			j = i + 1
			for j in range(i + 1, n):
				if s[j] != '1':
					break
			ln = j - i
			k = j + 1
			found = 0
			for k in range(j + 1, n):
				if s[k] != '0':
					found = 1
					break
			if found:
				to_next = k - j
			else:
				to_next = None
			if not upped:
				price += a
				upped = True
			price += (ln + 1) * b
			if not to_next:
				price += a
				break
			else:
				avar = a * 2
				bvar = b * (to_next - 1)
				if avar < bvar:
					price += avar
				else:
					price += bvar
				i = k
		else:
			i += 1
	print(price)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	description_of_the_road = [int(i) for i in input()]
	cost = 0
	if 1 in description_of_the_road:
		for (start, crossroad) in enumerate(description_of_the_road):
			if crossroad == 0:
				cost += a + b
			else:
				cost += a
				break
		end = n - 1
		while description_of_the_road[end] != 1:
			cost += a + b
			end -= 1
		else:
			cost += a
		num_of_zeros = []
		flag = 0
		for crossroad in range(start, end + 1):
			if description_of_the_road[crossroad] == 0 and flag == 0:
				flag = 1
				num_of_zeros.append(1)
			elif description_of_the_road[crossroad] == 0 and flag == 1:
				num_of_zeros[-1] += 1
			else:
				flag = 0
		cost -= a
		for zeros in num_of_zeros:
			if zeros != 1:
				if 2 * a < (zeros - 1) * b:
					cost += 2 * a + (zeros - 1) * b + (zeros - 1) * a
				else:
					cost += (zeros - 1) * 2 * b + (zeros - 1) * a
		num_of_ones = []
		for crossroad in range(start, end + 1):
			if description_of_the_road[crossroad] == 1 and flag == 0:
				flag = 1
				num_of_ones.append(1)
			elif description_of_the_road[crossroad] == 1 and flag == 1:
				num_of_ones[-1] += 1
			else:
				flag = 0
		for ones in num_of_ones:
			cost += (ones + 1) * 2 * b + (ones + 1) * a
	else:
		cost = a * n + b * (n + 1)
	print(cost)


from collections import defaultdict as dc
import sys
import math

def inp():
	p = sys.stdin.readline()
	return p
for _ in range(int(input())):
	(n, a, b) = list(map(int, inp().split()))
	s = str(input())
	h = 1
	x = n * a
	l = float('inf')
	p = [[l, l] for i in range(n + 1)]
	p[0][0] = b
	for i in range(n):
		if s[i] == '0':
			p[i + 1][0] = min(p[i + 1][0], p[i][0] + a + b)
			p[i + 1][1] = min(p[i + 1][1], p[i][1] + a + 2 * b)
			p[i + 1][0] = min(p[i + 1][0], p[i][1] + 2 * a + b)
			p[i + 1][1] = min(p[i + 1][1], p[i][0] + 2 * (a + b))
		else:
			p[i + 1][1] = min(p[i + 1][1], p[i][1] + a + 2 * b)
	print(p[n][0])


t = int(input())
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	ary = [[int(1e+99), int(1e+99)] for i in range(n + 1)]
	ary[0][0] = b
	for i in range(n):
		if s[i] == '0':
			ary[i + 1][0] = min(ary[i + 1][0], ary[i][0] + a + b)
			ary[i + 1][1] = min(ary[i + 1][1], ary[i][0] + 2 * (a + b))
			ary[i + 1][1] = min(ary[i + 1][1], ary[i][1] + a + 2 * b)
			ary[i + 1][0] = min(ary[i + 1][0], ary[i][1] + 2 * a + b)
		else:
			ary[i + 1][1] = min(ary[i + 1][1], ary[i][1] + a + 2 * b)
	print(ary[n][0])


from sys import stdin

def ii():
	return int(stdin.readline())

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

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

def si():
	return stdin.readline()
for _ in range(ii()):
	(n, a, b) = mi()
	s = si()
	(p, x, q) = (n + 2, 0, 2 * n)
	d = s.find('1')
	if d > -1:
		q -= d - 1
		e = s.rfind('1')
		q -= n - e - 2
		for i in range(d + 1, e + 1):
			if s[i] == '0':
				x += 1
			elif x:
				if a * (x + 1) + b * (x - 1) < a * (x - 1) + 2 * b * (x - 1):
					p += 2
					q -= x - 1
				x = 0
	else:
		p = n
		q = n + 1
	print(p * a + q * b)


from math import inf
t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input().strip()
	dp = [[inf, inf, inf] for _ in range(n + 1)]
	dp[0][1] = b
	for i in range(1, n + 1):
		idx = i - 1
		if s[idx] == '0':
			dp[i][1] = min(dp[i - 1][1] + a + b, dp[i - 1][2] + 2 * a + b)
			dp[i][2] = min(dp[i - 1][1] + 2 * a + 2 * b, dp[i - 1][2] + a + 2 * b)
		else:
			dp[i][1] = inf
			dp[i][2] = dp[i - 1][2] + a + 2 * b
	print(dp[n][1])


def handle_case(n, pipe, pillar, s):
	num_pipe = 0.5
	num_pillar = 1
	last = 'down'

	def increase_by(num_pipe, pipe_inc, num_pillar, pillar_inc):
		num_pipe += pipe_inc
		num_pillar += pillar_inc
		return (num_pipe, num_pillar)

	def is_good_to_down(i):
		nearest_one_indx = s[i:].find('1')
		if nearest_one_indx == -1:
			return ('down', i, 2, 2)
		nearest_minus_2 = nearest_one_indx - 1
		cost_of_down = 4 * pipe + 4 * pillar + nearest_minus_2 * (pipe + pillar)
		cost_of_up = 2 * pipe + 4 * pillar + nearest_minus_2 * (pipe + 2 * pillar)
		if cost_of_down < cost_of_up:
			return ('up', nearest_one_indx + i, 4 + nearest_minus_2, 4 + nearest_minus_2)
		else:
			return ('up', nearest_one_indx + i, 2 + nearest_minus_2, 4 + nearest_minus_2 * 2)
	i = 1
	while i < len(s):
		if ''.join([s[i - 1:i + 1]]) == '11':
			(num_pipe, num_pillar) = increase_by(num_pipe, 1, num_pillar, 2)
		elif ''.join([s[i - 1:i + 1]]) == '01':
			if last == 'down':
				(num_pipe, num_pillar) = increase_by(num_pipe, 2, num_pillar, 2)
				last = 'up'
			else:
				(num_pipe, num_pillar) = increase_by(num_pipe, 1, num_pillar, 2)
		elif ''.join([s[i - 1:i + 1]]) == '00':
			if last == 'down':
				(num_pipe, num_pillar) = increase_by(num_pipe, 1, num_pillar, 1)
			else:
				(num_pipe, num_pillar) = increase_by(num_pipe, 1, num_pillar, 2)
		elif ''.join([s[i - 1:i + 1]]) == '10':
			(last, i, pipe_inc, pillar_inc) = is_good_to_down(i)
			(num_pipe, num_pillar) = increase_by(num_pipe, pipe_inc, num_pillar, pillar_inc)
		i += 1
	num_pipe += 0.5
	num_pillar += 1
	cost = pipe * num_pipe + pillar * num_pillar
	print(int(cost))

def run():
	T = eval(input())
	queries = []
	for i in range(T):
		(n, a, b) = list(map(int, input().split()))
		s = input()
		queries.append((n, a, b, s))
	for query in queries:
		(n, a, b, s) = query
		handle_case(n, a, b, s)
run()


for _ in range(int(input())):
	(n, pipe_price, pillar_price) = map(int, input().split())
	s = input()
	ans = pillar_price * (n + 1) + pipe_price * n
	max_space = int(pipe_price * 2 / pillar_price)
	i = 0
	while i < n and s[i] == '0':
		i += 1
	if i == n:
		print(ans)
		continue
	j = n - 1
	while s[j] == '0':
		j -= 1
	s = s[i:j + 1]
	ans += pipe_price * 2 + (len(s) + 1) * pillar_price
	i = 0
	while i < len(s):
		seq = 0
		while s[i] == '0':
			seq += 1
			i += 1
		i += 1
		if seq - 1 > max_space:
			ans -= pillar_price * (seq - 1)
			ans += pipe_price * 2
	print(ans)


t = int(input())
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	p = []
	p1 = 0
	p2 = 0
	for j in range(n):
		if s[j] == '0':
			p1 += 1
			if p2 != 0:
				p.append(p2)
			p2 = 0
		else:
			p2 += 1
			if p1 != 0:
				p.append(p1)
			p1 = 0
	if p1 != 0:
		p.append(p1)
	if p2 != 0:
		p.append(p2)
	et = 0
	dld = 0
	dls = 1
	uk = 0
	for j in range(len(p)):
		if s[uk] == '0':
			if et == 0:
				if j == len(p) - 1:
					dld += p[j]
					uk += p[j]
					dls += p[j]
				else:
					et = 1
					dld += p[j] + 1
					dls += p[j] + 1
					uk += p[j]
			elif et == 1:
				if j == len(p) - 1:
					dld += 2 + p[j] - 1
					dls += p[j]
					uk += p[j]
				elif p[j] == 1:
					dld += 1
					uk += p[j]
					dls += 2
				elif (4 + p[j] - 2) * a + (p[j] - 1) * b <= p[j] * a + (p[j] - 1) * 2 * b:
					dld += 4 + p[j] - 2
					dls += p[j] + 1
					uk += p[j]
				else:
					dld += p[j]
					dls += p[j] * 2
					uk += p[j]
		else:
			dld += p[j]
			dls += p[j] * 2
			uk += p[j]
	print(dld * a + dls * b)


def get_road_chunk(cur_pos):
	r = cur_pos
	while r + 1 < len(s) and s[r + 1] == '0':
		r += 1
	return r - cur_pos + 1
T = int(input())
for i in range(T):
	(n, a, b) = map(int, input().split())
	s = input()
	k = 0
	p = b
	cur_level = 1
	while k < len(s):
		if s[k] == '1':
			p += a + 2 * b
			k += 1
		elif get_road_chunk(k) == 1:
			if cur_level == 1:
				p += 2 * a + 2 * b
				cur_level = 2
			elif k == len(s) - 1:
				p += a * 2 + b
			else:
				p += a + 2 * b
			k += 1
		else:
			l = get_road_chunk(k)
			if l + k != len(s):
				if cur_level == 2:
					if a * (l + 2) + b * (l + 1) < a * l + b * 2 * l:
						p += a * (l + 2) + b * (l + 1)
					else:
						p += a * l + b * 2 * l
				else:
					p += a * (l + 1) + b * (l + 1)
					cur_level = 2
			elif cur_level == 2:
				p += a * (l + 1) + b * l
			else:
				p += a * l + b * l
			k = k + l
	print(p)