You are given a string $s$ of length $n$ consisting only of the characters 0 and 1.

You perform the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue the remaining two parts together (any of them can be empty) in the same order. For example, if you erase the substring 111 from the string 111110, you will get the string 110. When you delete a substring of length $l$, you get $a \cdot l + b$ points.

Your task is to calculate the maximum number of points that you can score in total, if you have to make the given string empty.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 2000$) — the number of testcases.

The first line of each testcase contains three integers $n$, $a$ and $b$ ($1 \le n \le 100; -100 \le a, b \le 100$) — the length of the string $s$ and the parameters $a$ and $b$.

The second line contains the string $s$. The string $s$ consists only of the characters 0 and 1.


-----Output-----

For each testcase, print a single integer — the maximum number of points that you can score.


-----Examples-----

Input
3
3 2 0
000
5 -2 5
11001
6 1 -4
100111
Output
6
15
-2


-----Note-----

In the first example, it is enough to delete the entire string, then we will get $2 \cdot 3 + 0 = 6$ points.

In the second example, if we delete characters one by one, then for each deleted character we will get $(-2) \cdot 1 + 5 = 3$ points, i. e. $15$ points in total.

In the third example, we can delete the substring 00 from the string 100111, we get $1 \cdot 2 + (-4) = -2$ points, and the string will be equal to 1111, removing it entirely we get $1 \cdot 4 + (-4) = 0$ points. In total, we got $-2$ points for $2$ operations.

Difficulty: EASY
Tags: Mathematics

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
for i in range(int(input())):
	(n, a, b) = map(int, input().strip().split())
	s = input()
	c = 1
	for i in range(1, len(s)):
		if s[i] != s[i - 1]:
			c += 1
	if b >= 0:
		print(a * n + b * n)
	else:
		print(a * n + b * (c // 2 + 1))


from math import ceil
t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	new_str = ''
	i = 0
	while i < n:
		new_str += s[i]
		j = i
		while i < n and s[i] == s[j]:
			i += 1
	if b < 0:
		print(a * n + ceil((len(new_str) + 1) / 2) * b)
	else:
		print(n * (a + b))


t = int(input())
results = []
for i in range(t):
	(n, a, b) = map(int, input().split())
	digits = input()
	if b > 0:
		results.append(n * (a + b))
		continue
	current = None
	count = 0
	for j in range(n):
		if current != digits[j]:
			count += 1
			current = digits[j]
	results.append(n * a + b * (count // 2 + 1))
for i in range(t):
	print(results[i])


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	d = input()
	if b >= 0:
		print(n * a + b * n)
	else:
		print(n * a + b * (max((d.count('01'), d.count('10'))) + 1))


def solution(s, l, a, b):
	if b >= 0 or l == 1:
		return (a + b) * l
	else:
		c = 0
		for i in range(1, l):
			if s[i] != s[i - 1]:
				c += 1
		return ((c + 1) // 2 + 1) * b + a * l
n = int(input())
for _ in range(n):
	(l, a, b) = tuple(map(int, input().split()))
	s = input()
	print(solution(s, l, a, b))


def grup(l):
	count = 0
	j = l[0]
	for i in range(len(l)):
		if l[i] != j:
			count = count + 1
			j = l[i]
	return count + 1
for i in range(int(input())):
	(n, a, b) = map(int, input().split(' '))
	s = input()
	if b < 0:
		k = grup(s)
		ans = n * a + b * (k // 2 + 1)
	else:
		ans = n * (a + b)
	print(ans)


for i in range(int(input())):
	t = input().split()
	n = int(t[0])
	a = int(t[1])
	b = int(t[2])
	s = input()
	if b >= 0:
		print(n * a + n * b)
	else:
		k = 1
		for i in range(n - 1):
			if s[i] != s[i + 1]:
				k += 1
		print(n * a + (k // 2 + 1) * b)


def min_switches(s):
	cur = s[0]
	res = 1
	for e in s[1:]:
		if e != cur:
			res += 1
			cur = e
	return res

def test():
	(n, a, b) = [int(e) for e in input().split()]
	s = input()
	if b >= 0:
		print(a * n + b * n)
	else:
		print(a * n + (min_switches(s) // 2 + 1) * b)
for o in range(int(input())):
	test()


from sys import stdin, stdout, setrecursionlimit
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
from bisect import bisect_right as br, bisect_left as bl
import heapq
for _ in range(it()):
	(n, a, b) = mp()
	l = list(input())
	ans = 0
	if b > 0:
		for i in range(n):
			ans += a + b
		print(ans)
		continue
	else:
		v = []
		temp = 1
		for i in range(1, n):
			if l[i] == l[i - 1]:
				temp += 1
			else:
				v.append([l[i - 1], temp])
				temp = 1
		v.append([l[-1], temp])
		v = deque(v)
		while v:
			if len(v) > 1:
				if v[0][0] == v[-1][0]:
					ans += a * (v[0][1] + v[-1][1]) + b
					v.popleft()
					v.pop()
				elif v[0][1] < v[-1][1]:
					ans += a * v[0][1] + b
					v.popleft()
				else:
					ans += a * v[-1][1] + b
					v.pop()
			else:
				ans += a * v[0][1] + b
				v.pop()
		print(ans)


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		ans = n * (a + b)
		print(ans)
	else:
		ans = b
		i = s[0]
		j = i
		n = n * a
		for c in s:
			if c != i and j != c:
				ans += b
			j = c
		print(n + ans)


t = int(input())

def solve():
	(n, a, b) = map(int, input().split())
	s = input()
	segs = []
	run = 1
	curr = s[0]
	for i in range(1, len(s)):
		if curr == s[i]:
			run += 1
		else:
			segs.append(run)
			run = 1
			curr = s[i]
	segs.append(run)
	if b >= 0:
		print(int(len(s) * a + len(s) * b))
	else:
		ans = len(s) * a
		ans += len(segs) // 2 * b
		ans += b
		print(int(ans))
for i in range(t):
	solve()


from collections import defaultdict as df
import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	arr = [int(i) for i in input()]
	cons_s = a * n
	cons_time = 0
	w = 0
	bl = 0
	if arr[0]:
		w += 1
	else:
		bl += 1
	for i in range(1, n):
		if arr[i] != arr[i - 1]:
			if arr[i]:
				w += 1
			else:
				bl += 1
	cons_time = min(bl, w) + 1
	if a >= 0 and b >= 0:
		print(n * b + n * a)
	elif a < 0 and b < 0:
		print(cons_time * b + n * a)
	elif a >= 0 and b < 0:
		print(n * a + cons_time * b)
	else:
		print(n * b + n * a)


for i in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b > 0:
		print(n * (a + b))
	else:
		d = s.count('10') + s.count('01')
		print((d + 3) // 2 * b + n * a)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
MOD = 1000000007
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, a, b) = map(int, input().split(' '))
	s = input()
	c = 0
	l = '0'
	ans = 1
	for i in range(n - 1):
		if s[i] != s[i + 1]:
			ans += 1
	v = ans // 2 + 1
	print(max(a * n + b * n, a * n + b * v))


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	zeros = s.count('0')
	ones = n - zeros
	if b >= 0:
		print(n * (a + b))
	else:
		count = 1
		cur = s[0]
		for i in range(1, n):
			if s[i] != cur:
				count += 1
				cur = s[i]
		print(n * a + b * (count // 2 + 1))


from itertools import groupby
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	ans = 0
	if b >= 0:
		ans += n * (a + b)
	else:
		ans1 = 0
		ans2 = 0
		var1 = 0
		var2 = 0
		arr = [len(list(g)) for (k, g) in groupby(s)]
		for i in range(len(arr)):
			if i % 2 == 0:
				ans1 += a * arr[i] + b
				var2 += arr[i]
			else:
				ans2 += a * arr[i] + b
				var1 += arr[i]
		ans1 += a * var1 + b
		ans2 += a * var2 + b
		ans = max(ans1, ans2)
	print(ans)


from math import ceil, sqrt
t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	pt = 1
	cp = s[0]
	for c in s:
		if c != cp:
			pt += 1
			cp = c
	if b > 0:
		print((a + b) * len(s))
	else:
		print(a * len(s) + b * ceil((pt + 1) / 2))


import collections
import math
import collections
import sys
from functools import reduce
import decimal
sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP
graphDict = collections.defaultdict
queue = collections.deque()

class Graphs:

	def __init__(self):
		self.graph = graphDict(list)

	def add_edge(self, u, v):
		self.graph[u].append(v)

	def dfs_utility(self, nodes, visited_nodes):
		visited_nodes.add(nodes)
		for neighbour in self.graph[nodes]:
			if neighbour not in visited_nodes:
				self.dfs_utility(neighbour, visited_nodes)
			else:
				return neighbour

	def dfs(self, node):
		Visited = set()
		self.dfs_utility(node, Visited)

	def bfs(self, node):
		visited = set()
		if node not in visited:
			queue.append(node)
			visited.add(node)
		while queue:
			parent = queue.popleft()
			print(parent)
			for item in self.graph[parent]:
				if item not in visited:
					queue.append(item)
					visited.add(item)

def rounding(n):
	return int(decimal.Decimal(f'{n}').to_integral_value())

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

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

def map_inp(v_type):
	return map(v_type, inp().split())

def list_inp(v_type):
	return list(map_inp(v_type))
for _ in range(int(inp())):
	(n, a, b) = map_inp(int)
	arr = list(inp())
	if a >= 0 and b >= 0:
		print(len(arr) * (a + b))
	elif b >= 0:
		print(len(arr) * (a + b))
	else:
		dic = []
		for i in range(len(arr)):
			if i == 0:
				dic.append(1)
				continue
			if arr[i] == arr[i - 1]:
				dic[len(dic) - 1] += 1
			else:
				dic.append(1)
		even_sum = 0
		odd_sum = 0
		for i in range(len(dic)):
			if i & 1 == 0:
				even_sum += dic[i]
			else:
				odd_sum += dic[i]
		(ans1, ans2) = (0, 0)
		ans1 += a * even_sum + b
		for i in range(1, len(dic), 2):
			ans1 += a * dic[i] + b
		ans2 += a * odd_sum + b
		for i in range(0, len(dic), 2):
			ans2 += a * dic[i] + b
		print(max(ans1, ans2))


import sys
import math

def solver(n: int, s: str, f: object, is_cool: bool) -> int:
	if is_cool:
		bit = s[0]
	else:
		return n * f(1)
	cur_l = 0
	sum_l = 0
	points = 0
	for c in s:
		if c != bit:
			cur_l += 1
		else:
			sum_l += 1
			if cur_l > 0:
				points += f(cur_l)
			cur_l = 0
	if cur_l > 0:
		points += f(cur_l)
	if sum_l > 0:
		points += f(sum_l)
	return points

def main():
	t = int(sys.stdin.readline())
	for _ in range(t):
		(n, a, b) = list(map(int, sys.stdin.readline().split()))
		s = sys.stdin.readline().strip()
		f = lambda l: a * l + b
		is_cool = b < 0
		res = solver(n, s, f, is_cool)
		sys.stdout.write(str(res) + '\n')
main()


from math import ceil

def minSteps(S):
	new_str = ''
	N = len(S)
	i = 0
	while i < N:
		new_str += S[i]
		j = i
		while i < N and S[i] == S[j]:
			i += 1
	return ceil((len(new_str) + 1) / 2)
t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	S = '100111'
	if b < 0:
		print(a * n + minSteps(s) * b)
	else:
		print(a * n + n * b)


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

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

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

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

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

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

def solve():
	for _ in range(1, ii() + 1):
		(n, a, b) = mi()
		s = si()
		if a + b >= a:
			print(n * (a + b))
			continue
		else:
			x = []
			c = 1
			for i in range(1, n):
				if s[i] != s[i - 1]:
					x.append(c)
					c = 1
				else:
					c += 1
			x.append(c)
			(cnt, cnt1, cnt3, cnt2) = (0, 0, 0, 0)
			for i in range(len(x)):
				if i % 2 == 0:
					cnt += x[i] * a + b
					cnt3 += x[i]
				else:
					cnt1 += x[i] * a + b
					cnt2 += x[i]
			cnt += cnt2 * a + b
			cnt1 += cnt3 * a + b
			print(max(cnt, cnt1))
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


def solve():
	t = int(input())
	for _ in range(t):
		(n, a, b) = [int(x) for x in input().split()]
		s = input()[:n]
		k = 0
		if b >= 0:
			k = n
		if b < 0:
			section_0_num = 0
			section_1_num = 0
			last_c = ''
			for c in s:
				if c == last_c:
					continue
				last_c = c
				if c == '0':
					section_0_num += 1
				else:
					section_1_num += 1
			k = max(section_0_num, section_1_num)
			if section_0_num == section_1_num:
				k += 1
		print(a * n + k * b)
solve()


t = int(input())
fridge1 = list()
fridge2 = list()
fridge2_pererab = list()
fridge_answer = list()
for i in range(t):
	fridge1.append(list(map(int, input().split())))
	fridge2.append(input())
for i in range(len(fridge2)):
	fridge2_pererab.append(list())
	d = ''
	for j in range(len(fridge2[i])):
		if j == 0:
			d += fridge2[i][j]
		elif fridge2[i][j] == fridge2[i][j - 1]:
			d += fridge2[i][j]
		else:
			fridge2_pererab[i].append(d)
			d = ''
			d += fridge2[i][j]
		if len(fridge2[i]) - 1 == j:
			fridge2_pererab[i].append(d)
for i in range(len(fridge2_pererab)):
	counter = 0
	s = fridge2_pererab[i]
	a = fridge1[i][1]
	b = fridge1[i][2]
	if b >= 0:
		for j in range(len(s)):
			counter += a * len(s[j]) + b * len(s[j])
	else:
		form = len(s) // 2 + 1
		counter += a * len(fridge2[i]) + b * form
	fridge_answer.append(counter)
print(*fridge_answer, sep='\n')


for _ in range(int(input())):
	(n, a, b) = [int(i) for i in input().split()]
	k = input()
	print(n * a + b * n) if b >= 0 else print(n * a + b * (max(k.count('01'), k.count('10')) + 1))
arr_inp = lambda : list(map(int, input().split()))
sp_inp = lambda : map(int, input().split())
str_inp = lambda : input()


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	ans = a * n
	c = 0
	for x in range(1, n):
		if s[x] != s[x - 1]:
			c += 1
	k = max(b * n, b * ((c + 1) // 2 + 1))
	print(ans + k)


t = int(input())
for _ in range(t):
	(n, a, b) = list(map(int, input().split()))
	s = input()
	if b >= 0:
		print((a + b) * n)
	else:
		kol = 0
		for i in range(1, n):
			if s[i] != s[i - 1]:
				kol += 1
		print(n * a + ((kol + 1) // 2 + 1) * b)


def f(s, a, b):
	left = 0
	tmp = []
	for right in range(1, len(s)):
		if s[right] != s[left]:
			tmp.append(right - left)
			left = right
	if len(s) - left:
		tmp.append(len(s) - left)
	ret = 0
	if b >= 0:
		for l in tmp:
			ret += a * l + b * l
	else:
		ret1 = 0
		s = sum(tmp)
		for l in range(0, len(tmp), 2):
			s -= l
			ret1 += a * l + b
		ret1 += s * a + b
		ret2 = 0
		s = sum(tmp)
		for l in range(1, len(tmp), 2):
			s -= l
			ret2 += a * l + b
		ret2 += s * a + b
		ret = max(ret1, ret2)
	return ret
for _ in range(int(input())):
	(_, a, b) = [int(i) for i in input().split()]
	s = input()
	print(f(s, a, b))


for _ in range(int(input())):
	(n, a, b) = [int(i) for i in input().split()]
	k = input()
	print(n * a + b * n) if b >= 0 else print(n * a + b * (max(k.count('01'), k.count('10')) + 1))


from collections import Counter, defaultdict
from math import ceil

def minSteps(S):
	new_str = ''
	N = len(S)
	i = 0
	while i < N:
		new_str += S[i]
		j = i
		while i < N and S[i] == S[j]:
			i += 1
	ans = ceil((len(new_str) + 1) / 2)
	return ans
for i in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	minv = minSteps(s)
	ans = float('-inf')
	for j in range(minv, n + 1):
		ans = max(ans, j * b + n * a)
	print(ans)


from math import gcd
t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	if b > 0:
		print(a * n + b * n)
	else:
		mini = max(s.count('01') + 1, s.count('10') + 1)
		ans = mini * b
		print(a * n + ans)


import heapq, math
from collections import defaultdict, deque
from os import getcwd
import sys, os.path
if os.path.exists('C:/Users/Dhanush/Desktop/cp/input.txt'):
	sys.stdout = open('C:/Users/Dhanush/Desktop/cp/output.txt', 'w')
	sys.stdin = open('C:/Users/Dhanush/Desktop/cp/input.txt', 'r')

def fun():
	res = []
	i = 1
	c = 1
	while i < n:
		if s[i] == s[i - 1]:
			c += 1
		else:
			res.append(c)
			c = 1
		i += 1
	res.append(c)
	ans = 0
	ans1 = 0
	i = 0
	while i < len(res):
		ans1 += res[i] * a + b
		i += 1
	i = 1
	while i < len(res):
		ans += res[i] * a + b
		i += 2
	c = 0
	i = 0
	while i < len(res):
		c += res[i]
		i += 2
	ans += c * a + b
	return max(ans, ans1)
tc = int(input())
for _ in range(tc):
	(n, a, b) = map(int, input().split())
	s = input().strip()
	ans1 = n * a + n * b
	ans2 = fun()
	print(max(ans1, ans2))


import sys
input = sys.stdin.readline

def solve():
	(n, a, b) = map(int, input().split())
	s = input().strip()
	cnt = 0
	for i in range(n - 1):
		if s[i] != s[i + 1]:
			cnt += 1
	return a * n + max(((cnt + 1) // 2 + 1) * b, n * b)
for _ in range(int(input())):
	print(solve())


import sys

def fun(a, b, s, n):
	if n == 1:
		return a * 1 + b
	if b > 0:
		return (a + b) * n
	temp = 0
	pre = s[0]
	for i in range(1, n):
		cur = s[i]
		if cur != pre:
			temp += 1
			pre = s[i]
	temp += 1
	temp = temp // 2
	temp += 1
	return a * n + b * temp
t = int(sys.stdin.readline())
for i in range(t):
	(n, a, b) = map(int, sys.stdin.readline().split())
	s = sys.stdin.readline()
	print(fun(a, b, s, n))


for t in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	c = max(s.count('01'), s.count('10')) + 1
	if b == abs(b):
		print(a * n + b * n)
	else:
		print(a * n + b * c)


from math import *
from sys import *
from bisect import *
from collections import *
t = int(stdin.readline())
for _ in range(t):
	(n, a, b) = map(int, stdin.readline().split())
	s = stdin.readline()
	if b >= 0:
		ans = n * (a + b)
		print(ans)
	else:
		z = 0
		o = 0
		f = 0
		for i in range(n):
			if s[i] == '0' and f == 0:
				z += 1
				f = 1
			elif s[i] == '1':
				f = 0
		f = 0
		for i in range(n):
			if s[i] == '1' and f == 0:
				o += 1
				f = 1
			elif s[i] == '0':
				f = 0
		x = min(z, o)
		ans = b * x + b
		ans += n * a
		print(ans)


n = int(input())
i = 0
while i < n:
	(t, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print(a * t + b * t)
	else:
		print(t * a + b * (max((s.count('01'), s.count('10'))) + 1))
	i += 1


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
t = int(input())
for w in range(t):
	(n, a, b) = (int(i) for i in input().split())
	s = list(input())
	l = []
	prev = s[0]
	c = 1
	if s[0] == '1':
		c1 = 1
		c2 = 0
	else:
		c2 = 1
		c1 = 0
	for i in range(1, n):
		if s[i] == prev:
			c += 1
		else:
			l.append(c)
			if s[i] == '1':
				c1 += 1
			else:
				c2 += 1
			c = 1
		prev = s[i]
	l.append(c)
	k = len(l)
	if b >= 0:
		print((a + b) * n)
	elif c1 < c2:
		print(a * n + b * (c1 + 1))
	else:
		print(a * n + b * (c2 + 1))


import math
t = int(input())
while t > 0:
	(n, a, b) = input().split()
	n = int(n)
	a = int(a)
	b = int(b)
	s = input()
	s += '-'
	res = a * n
	if b >= 0:
		res += b * n
	else:
		old = s[0]
		(cnt1, cnt2) = (0, 0)
		for i in range(1, len(s)):
			if s[i] == old:
				continue
			else:
				if old == '1':
					cnt1 += 1
				else:
					cnt2 += 1
				old = s[i]
		res += min(cnt1 + 1, cnt2 + 1) * b
	print(res)
	t = t - 1


def solve(n, a, b, s):
	if b >= 0:
		print(n * (a + b))
		return
	count = 0
	for i in range(1, n):
		if s[i] != s[i - 1]:
			count += 1
	if count % 2 == 0:
		count //= 2
	else:
		count //= 2
		count += 1
	count += 1
	print(a * n + b * count)
t = int(input())
for z in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	solve(n, a, b, s)


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

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()
from os import path
import bisect
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output1.txt', 'w')
from heapq import heappop, heappush, heapify
from math import ceil, log
from collections import defaultdict, deque
maxi = sys.maxsize
mini = -maxi
mod = 998244353
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		ans = n * (a + b)
		print(ans)
	else:
		ans = b
		i = s[0]
		j = i
		n = n * a
		for c in s:
			if c != i and j != c:
				ans += b
			j = c
		print(n + ans)


import math
t = int(input())
for __ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	if b > 0:
		print(n * (a + b))
	else:
		j = s[0]
		count = 1
		for i in s:
			if j != i:
				count += 1
				j = i
		print(n * a + b * ((count + 2) // 2))


import sys, os
import math
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
from io import BytesIO, IOBase
from heapq import *
from bisect import *
from collections import Counter

def main():
	for _ in range(int(input())):
		(n, a, b) = MI()
		s = input()
		if b >= 0:
			print(n * (a + b))
		else:
			(z, o) = (0, 0)
			if s[0] == '1':
				o += 1
			else:
				z += 1
			for i in range(1, n):
				if s[i] == s[i - 1]:
					continue
				elif s[i] == '1':
					o += 1
				else:
					z += 1
			print(n * a + (min(z, o) + 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')

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

def mi():
	return int(input())

def outP(var):
	sys.stdout.write(str(var) + '\n')
MOD = 10 ** 9 + 7
mod = 998244353
main()


import sys as _sys

def find_max_score(string, a, b):
	intermediate_result = len(string) * a
	del a
	if b >= 0:
		operations_n = _find_max_operations_n(string)
	else:
		operations_n = _find_min_operations_n(string)
	result = intermediate_result + b * operations_n
	return result

def _find_max_operations_n(string):
	return len(string)

def _find_min_operations_n(string):
	while '00' in string:
		string = string.replace('00', '0')
	while '11' in string:
		string = string.replace('11', '1')
	groups_n = len(string)
	if groups_n == 0:
		return 0
	return groups_n // 2 + 1

def _main():
	[tests_n] = _read_ints()
	for i_test in range(tests_n):
		[s_length, a, b] = _read_ints()
		s = _read_string()
		assert len(s) == s_length
		result = find_max_score(s, a, b)
		print(result)

def _read_string():
	return _sys.stdin.readline()[:-1]

def _read_ints():
	return map(int, _read_string().split())
_main()


for q in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	zcount = len(list(filter(None, s.split('1'))))
	ncount = len(list(filter(None, s.split('0'))))
	count = min(zcount, ncount) + 1
	if b > 0:
		print(n * (a + b))
	else:
		print(n * a + count * b)


def one_zero(st, a, b):
	if b >= 0:
		return (a + b) * len(st)
	num = 1
	for i in range(1, len(st)):
		if st[i] != st[i - 1]:
			num += 1
	return (num // 2 + 1) * b + a * len(st)
t = int(input())
for i in range(t):
	p = input().split()
	st = input()
	print(one_zero(st, int(p[1]), int(p[2])))


for case in range(int(input())):
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	n = list(s)[0]
	lis = [n]
	for m in list(s):
		if m != n:
			lis.append(m)
			n = m
		else:
			pass
	count_1 = len(list(filter(lambda x: x == '1', lis)))
	count_0 = len(list(filter(lambda x: x == '0', lis)))
	least = min(count_0, count_1) + 1
	if b > 0:
		print(a * len(list(s)) + b * len(list(s)))
	else:
		print(a * len(list(s)) + b * least)


def slove():
	(n, a, b) = [int(x) for x in input().split(' ')]
	s = input()
	dem = 1
	for i in range(1, len(s)):
		if s[i] != s[i - 1]:
			dem += 1
	res = a * len(s) + (dem // 2 + 1) * b
	res1 = a * len(s) + b * len(s)
	print(max(res, res1))
t = int(input())
while t > 0:
	slove()
	t -= 1


import sys
import math

def solve(s, n, a, b):
	ans = 0
	subs = []
	cur = s[0]
	j = 0
	for i in range(n):
		if s[i] == cur:
			j += 1
		else:
			subs.append(j)
			cur = s[i]
			j = 1
	subs.append(j)
	if b < 0:
		n2 = len(subs) // 2 + 1
		ans = n * a + n2 * b
	else:
		ans = n * (a + b)
	return ans
t = int(input())
for i in range(t):
	[n, a, b] = [int(x) for x in input().split()]
	s = input()
	print(solve(s, n, a, b))


t = int(input())
for _ in range(t):
	(n, a, b) = [int(i) for i in input().split()]
	s = input()
	score = 0
	if b >= 0:
		score = a * n + b * n
	else:
		zeroes_lengths = []
		ones_lengths = []
		cur_len = 1
		last = False
		if n == 1:
			if s[0] == 0:
				zeroes_lengths.append(cur_len)
			else:
				ones_lengths.append(cur_len)
		for i in range(n - 1):
			if s[i] != s[i + 1]:
				if i == n - 2:
					last = True
				if s[i] == '0':
					zeroes_lengths.append(cur_len)
					if last:
						ones_lengths.append(1)
				else:
					ones_lengths.append(cur_len)
					if last:
						zeroes_lengths.append(1)
				cur_len = 1
			elif i == n - 2:
				cur_len += 1
				if s[i] == '0':
					zeroes_lengths.append(cur_len)
				else:
					ones_lengths.append(cur_len)
			else:
				cur_len += 1
		zeroes_groups = len(zeroes_lengths)
		ones_groups = len(ones_lengths)
		if zeroes_groups <= ones_groups:
			score = a * sum(zeroes_lengths) + b * zeroes_groups + a * sum(ones_lengths) + b
		else:
			score = a * sum(ones_lengths) + b * ones_groups + a * sum(zeroes_lengths) + b
	print(score)


t = int(input())
for i in range(t):
	(n, a, b) = input().split()
	s = input()
	n = int(n)
	a = int(a)
	b = int(b)
	if b >= 0:
		p = n * (a + b)
		print(p)
	else:
		r = s.replace('0', ' ')
		u = r.split()
		v = len(u)
		e = s.replace('1', ' ')
		f = e.split()
		g = len(f)
		if v >= g:
			k = a * n + (g + 1) * b
		else:
			k = a * n + (v + 1) * b
		print(k)


import sys
import math
from math import gcd
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)
N = 20005
T = 1
T = int(stdin.readline())
alp = 'abcdefghijklmnopqrstuvwxyz1234567890 '
for _ in range(T):
	(n, a, b) = list(map(int, stdin.readline().rstrip().split()))
	s = str(stdin.readline().strip('\n'))
	p = [0] * n
	p[0] = 1
	for i in range(n):
		if i != 0:
			if s[i] == s[i - 1]:
				p[i] = p[i - 1] + 1
			else:
				p[i] = 1
	seg = []
	for i in range(n):
		if i != 0:
			if p[i] == 1:
				seg.append(p[i - 1])
	seg.append(p[-1])
	if b >= 0:
		print(n * (a + b))
	else:
		print(a * n + (len(seg) // 2 + 1) * b)


test = int(input())
for _ in range(test):
	(n, a, b) = map(int, input().split())
	s = input()
	print(max(n * (b + a), n * a + b * (max(s.count('01'), s.count('10')) + 1)))


for i in range(0, int(input())):
	(n, a, b) = (int(x) for x in input().split())
	s = input()
	if b >= 0:
		print(a * n + b * n)
	else:
		print(a * n + b * (max(s.count('01'), s.count('10')) + 1))


import math
t = int(input())
for i in range(0, t):
	(n, a, b) = map(int, input().split())
	s = str(input())
	if a > -1 and b > -1:
		print(a * n + b * n)
	elif b > -1:
		print(a * n + b * n)
	else:
		l = list(s)
		p0 = []
		p1 = []
		c = 0
		k = 0
		for i in range(0, len(l)):
			l[i] = int(l[i])
			if i == 0:
				k = l[i]
				c = 1
			elif l[i] != k and i != 0:
				if k == 1:
					p1.append(c)
					k = 0
					c = 1
				else:
					p0.append(c)
					k = 1
					c = 1
			else:
				c = c + 1
		if k == 1:
			p1.append(c)
		else:
			p0.append(c)
		l1 = len(p0)
		l2 = len(p1)
		print(n * a + (min([l1, l2]) + 1) * b)


t = int(input())
for i in range(0, t):
	L = list(map(int, input().split()))
	s = str(input())
	l = L[0]
	a = L[1]
	b = L[2]
	if b >= 0 or l == 1:
		print((a + b) * l)
	else:
		ctr = 0
		s += '2'
		for j in range(1, l + 1):
			if s[j] != s[j - 1]:
				ctr += 1
		turns = (ctr + 2) // 2
		ans = a * l + b * turns
		print(ans)


l = int(input())
for i in range(l):
	(n, a, b) = map(int, input().split())
	s = input()
	r = 0
	if b >= 0:
		r = (a * 1 + b) * len(s)
	else:
		while s:
			f = '0' if s[0] == '1' else '1'
			c1 = s.find(f)
			c2 = s.find(s[0], c1)
			if c1 == -1:
				c1 = 0
				c2 = len(s)
			elif c2 == -1:
				c2 = len(s)
			r += a * len(s[c1:c2]) + b
			s = s[0:c1] + s[c2:]
	print(r)


num_cases = int(input())

def count_groups(bit_str):
	curr = bit_str[0]
	num_groups = 1
	for i in bit_str:
		if i != curr:
			num_groups += 1
			curr = i
	return num_groups
for _ in range(num_cases):
	(str_len, a, b) = [int(x) for x in input().split(' ')]
	bit_str = input()
	if b >= 0:
		print(str_len * (a + b))
	else:
		print(str_len * a + (count_groups(bit_str) // 2 + 1) * b)


import math

def minDel(x):
	c = x[0]
	p = 0
	for d in x:
		p = p + (d != c)
		c = d
	return 1 + math.ceil(p / 2)
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	k = input()
	s = minDel(k)
	print(max(a * n + b * s, a * n + b * n))


t = int(input())
for i in range(t):
	q = list(map(int, input().split()))
	s = input()
	if q[2] >= 0:
		print(q[0] * (q[2] + q[1]))
	else:
		ans = [1]
		sofar = [s[0]]
		i = 1
		res = 0
		while i < len(s):
			if s[i] == sofar[-1]:
				ans[-1] += 1
				i += 1
			else:
				ch = sofar[-1]
				num = ans[-1]
				if len(sofar) > 1:
					res = res + q[1] * num + q[2]
					sofar.pop()
					ans.pop()
					ans[-1] += 1
				else:
					sofar.append(s[i])
					ans.append(1)
				i += 1
		if len(ans) > 1:
			print(res + (q[1] * ans[0] + q[2]) + (q[1] * ans[1] + q[2]))
		else:
			print(res + q[1] * ans[0] + q[2])


def solve(n, a, b, s):
	p = ''
	c = 0
	for i in s:
		if i != p:
			p = i
			c += 1
	c = c // 2 + 1
	print(max(n * a + b * n, a * n + b * c))
(t,) = map(int, input().split())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	solve(n, a, b, s)


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

def solve():
	for _ in range(int(input())):
		(n, a, b) = li()
		s = input()
		ans = n * a
		if b >= 0:
			ans += n * b
		else:
			ans += b * max(s.count('01') + 1, s.count('10') + 1)
		print(ans)
solve()


import sys
import collections
import math
inf = sys.maxsize

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

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

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	(n, a, b) = get_ints()
	s = input()
	(zeros, ones) = ([], [])
	cnt = 1
	for i in range(1, len(s)):
		if s[i] == s[i - 1]:
			cnt += 1
		else:
			if s[i - 1] == '0':
				zeros.append(cnt)
			else:
				ones.append(cnt)
			cnt = 1
	if s[-1] == '0':
		zeros.append(cnt)
	else:
		ones.append(cnt)
	if b < 0:
		res1 = 0
		res2 = 0
		sum1 = sum(ones)
		sum2 = sum(zeros)
		for i in range(len(zeros)):
			res1 += zeros[i] * a + b
		res1 += sum1 * a + b
		for i in range(len(ones)):
			res2 += ones[i] * a + b
		res2 += sum2 * a + b
		print(max(res1, res2))
	else:
		print(len(s) * a + len(s) * b)


import os, sys
from io import BytesIO, IOBase

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, 8192))
			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, 8192))
			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')
inp = lambda dtype: dtype(input().strip())
inp_d = lambda dtype: [dtype(x) for x in input().split()]
inp_2d = lambda dtype, n: [inp(dtype) for _ in range(n)]
inp_2ds = lambda dtype, n: [inp_d(dtype) for _ in range(n)]
inp_enu = lambda dtype: [(i, x) for (i, x) in enumerate(inp_d(dtype))]
inp_enus = lambda dtype, n: [[i, inp_d(dtype)] for i in range(n)]
ceil1 = lambda a, b: (a + b - 1) // b
for _ in range(inp(int)):
	(n, a, b) = inp_d(int)
	(s, cost) = (inp(str), a * n)
	if b >= 0:
		cost += b * n
	else:
		(lst, num) = (s[0], 1)
		for i in s:
			if i != lst:
				num += 1
			lst = i
		cost += ceil1(num + 1, 2) * b
	print(cost)


for _ in range(int(input())):
	(n, a, b) = [int(o) for o in input().split()]
	s = input()
	if b >= 0:
		print(n * a + n * b)
	else:
		print(n * a + b * (max(s.count('01'), s.count('10')) + 1))


import sys
input = sys.stdin.buffer.readline
for t in range(int(input())):
	(N, A, B) = map(int, input().split())
	S = list(input())
	while len(S) > N:
		del S[-1]
	for i in range(N):
		S[i] -= 48
	ANS = A * N
	if B >= 0:
		ANS += B * N
	else:
		C = 3
		for i in range(1, N):
			if S[i] != S[i - 1]:
				C += 1
		ANS += B * (C >> 1)
	print(ANS)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print(n * a + b * n)
	elif b < 0:
		summ = 0
		stack = []
		j = 1
		i = 0
		while i < n:
			count = 0
			f = 0
			while j < n and s[i] != s[j]:
				f = 1
				count += 1
				j += 1
			stack.append(s[i])
			if f == 1:
				summ += count * a + b
			f = 0
			i = j
			j += 1
		while stack:
			summ += a
			p = stack.pop()
			if len(stack) == 0 or stack[-1] != p:
				summ += b
		print(summ)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b < 0:
		c0 = s.count('0')
		c1 = len(s) - c0
		if s.count('01') > s.count('10'):
			k = s.count('01')
			print(a * n + k * b + b)
		else:
			k = s.count('10')
			print(a * n + k * b + b)
	else:
		print(len(s) * (a + b))


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


def Maximum_deletion(s, n, a, b):
	res = 1
	for i in range(1, len(s)):
		if s[i] != s[i - 1]:
			res += 1
	if b >= 0:
		return n * (a + b)
	else:
		return n * a + (res // 2 + 1) * b
t = int(input())
for _ in range(t):
	(n, a, b) = list(map(int, input().split()))
	s = input()
	print(Maximum_deletion(s, n, a, b))


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	c = a
	a = list(input())
	dp = []
	now = 1
	for i in range(1, n):
		if a[i] == a[i - 1]:
			now += 1
		else:
			dp.append(now)
			now = 1
	dp.append(now)
	ans = 0
	a = c
	for i in range(len(dp)):
		ans = ans + max(dp[i] * a + b, dp[i] * a + dp[i] * b)
	if b < 0:
		now = 0
		s = 0
		for i in range(0, len(dp), 2):
			now += dp[i]
			s += dp[i] * a + b
		now1 = sum(dp) - now
		s = s + now1 * a + b
		now = 0
		s1 = 0
		for i in range(1, len(dp), 2):
			now += dp[i]
			s1 += dp[i] * a + b
		now1 = sum(dp) - now
		s1 = s1 + now1 * a + b
		print(max(s, s1, ans))
	else:
		print(ans)


t = int(input())
for _ in range(t):
	(n, a, b) = list(map(int, input().split()))
	s = input()
	if n == 1:
		print(a * 1 + b)
		continue
	if s[0] != s[-1]:
		ans = 0
		ones_count = 0
		total_count = 0
		for i in range(n):
			if s[i] == '1':
				ones_count += 1
				total_count += 1
			elif s[i] != '1' and ones_count > 0:
				ans += a * ones_count + b
				ones_count = 0
		if ones_count > 0:
			ans += a * ones_count + b
		ans += a * (n - total_count) + b
		print(max(ans, len(s) * (a + b)))
	else:
		target = ''
		if s[0] == '1':
			target += '0'
		else:
			target += '1'
		ans = 0
		ones_count = 0
		total_count = 0
		for i in range(n):
			if s[i] == target:
				ones_count += 1
				total_count += 1
			elif s[i] != target and ones_count > 0:
				ans += a * ones_count + b
				ones_count = 0
		if ones_count > 0:
			ans += a * ones_count + b
		ans += a * (n - total_count) + b
		print(max(ans, len(s) * (a + b)))


from itertools import combinations_with_replacement
import sys
from sys import stdin
import math
import bisect

def BinarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

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

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

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

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

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

def flinput():
	return list(map(int, stdin.readline().strip().split()))
for _ in range(iinput()):
	(n, a, b) = minput()
	ll = input()
	if a <= 0 and b >= 0 or (a >= 0 and b >= 0):
		print(n * (a + b))
	elif a >= 0 and b <= 0 or (a <= 0 and b <= 0):
		list1 = ll.split('0')
		list2 = ll.split('1')
		l1 = []
		l2 = []
		for i in list1:
			if i != '':
				l1.append(i)
		for i in list2:
			if i != '':
				l2.append(i)
		s = 0
		if len(l1) <= len(l2):
			for i in l1:
				s += a * len(i) + b
			ll = 0
			for i in l2:
				ll += len(i)
			s += a * ll + b
			print(s)
		else:
			for i in l2:
				s += a * len(i) + b
			ll = 0
			for i in l1:
				ll += len(i)
			s += a * ll + b
			print(s)


t = int(input())
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	count = n * a
	r = 0
	if b >= 0:
		count += n * b
	else:
		r = 1
		for k in range(1, len(s)):
			if s[k] != s[k - 1]:
				r += 1
		count += (r // 2 + 1) * b
	print(count)


import sys
MOD = 1000000007

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

def ii():
	return int(inp())

def iis():
	return [int(i) for i in inp().split()]

def solve():
	(n, a, b) = iis()
	s = inp()
	if b >= 0:
		return (a + b) * n
	signChanges = 1
	prev = s[0]
	for i in range(1, n):
		if s[i] != prev:
			signChanges += 1
			prev = s[i]
	return a * n + b * (1 + signChanges // 2)
t = ii()
for _ in range(t):
	print(solve())


import math
for t in range(int(input())):
	x = list(map(int, input().split()))
	s = list(input())
	counter = 0
	n = x[0]
	a = x[1]
	b = x[2]
	for i in range(len(s) - 1):
		if s[i] == s[i + 1]:
			continue
		else:
			counter += 1
	ans = math.ceil(counter / 2) + 1
	if b > 0:
		print(n * (a + b))
	else:
		print(n * a + ans * b)


def count_blocks(s):
	n_blocks = 0
	prev = '2'
	for c in s:
		if prev != c:
			n_blocks += 1
			prev = c
	return n_blocks
t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	n_blocks = count_blocks(s)
	if b < 0:
		answer = (n_blocks // 2 + 1) * b + n * a
	else:
		answer = n * b + n * a
	print(answer)


def solve(a, b, n, s):
	ans = 0
	to_find = str(1 - int(s[0]))
	firssst = 1
	sssecond = 0
	if s.find(to_find) >= 1:
		for i in range(1, n):
			if s[i] != to_find:
				firssst += 1
				if sssecond:
					ans += a * sssecond + b
				sssecond = 0
			else:
				sssecond += 1
				if i == n - 1:
					ans += a * sssecond + b
		ans += a * firssst + b
		print(ans)
	else:
		print(a * n + b)
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if a == 0:
		if b > 0:
			print(b * n)
		elif b == 0:
			print(0)
		else:
			solve(a, b, n, s)
	elif a > 0:
		if b > 0:
			print(a * n + b * n)
		elif b == 0:
			print(a * n)
		else:
			solve(a, b, n, s)
	elif b > 0:
		print(a * n + b * n)
	else:
		solve(a, b, n, s)


def f(l):
	x = 0
	for i in range(len(l) - 1):
		if l[i] != l[i + 1]:
			x = x + 1
	return x + 1

def g(l, n, a, b):
	if b >= 0:
		return n * (a + b)
	else:
		return n * a + (f(l) // 2 + 1) * b
t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	l = str(input())
	print(g(l, n, a, b))


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print(n * (a + b))
	else:
		o = 0
		z = 0
		x = int(s[0])
		y = int(s[0])
		w = 1
		for i in s:
			i = int(i)
			if i == 1:
				o += 1
			else:
				z += 1
			if i != y:
				w += 1
				y = i
		if z == 0 or o == 0:
			print(n * a + b)
		else:
			print(n * a + (w // 2 + 1) * b)


T = int(input())
for t in range(T):
	(n, a, b) = map(int, input().split())
	l = list(map(int, list(input())))
	if b >= 0:
		ans = a * n + b * n
	if b < 0:
		cnt = 0
		pre = l[0]
		for i in range(1, n):
			if pre != l[i]:
				cnt += 1
			pre = l[i]
		cnt += 1
		k = cnt // 2 + 1
		ans = a * n + b * k
	print(ans)


N = int(input())
final = []
for x in range(N):
	(s, a, b) = list(map(int, input().split()))
	string_input = input()
	if b >= 0:
		final.append(a * s + b * s)
	else:
		count = 0
		if string_input[0] == '1':
			count = string_input.count('10')
		else:
			count = string_input.count('01')
		final.append(a * s + b * (count + 1))
for x in final:
	print(x)


def solve():
	(n, a, b) = map(int, input().split())
	s = input()
	m = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			m += 1
	m = (m >> 1) + 1
	score = 0
	if a != 0:
		score += a * n
	if b != 0:
		score += b * (n if b > 0 else m)
	print(score)
for _ in range(int(input())):
	solve()


def solve(n, a, b, s):
	if b >= 0:
		ans = n * (a + b)
		print(ans)
		return
	ans = n * a
	final = [s[0]]
	current = s[0]
	for i in range(1, n):
		if s[i] != current:
			current = s[i]
			final.append(current)
	req = (len(final) // 2 + 1) * b
	print(ans + req)
T = int(input())
while T:
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	solve(n, a, b, s)
	T -= 1


def solve(a, b, n, s):
	if b >= 0:
		print(n * (a + b))
	else:
		result = n * a
		temp = s[0]
		count = 1
		for x in range(1, n):
			if temp != s[x]:
				temp = s[x]
				count += 1
		result += (count // 2 + 1) * b
		print(result)
for _ in range(int(input())):
	(n, a, b) = list(map(int, input().split()))
	s = input()
	solve(a, b, n, s)


x = int(input())
for i in range(x):
	(n, a, b) = input().split()
	x = input()
	n = int(n)
	a = int(a)
	b = int(b)
	if b >= 0:
		print(a * n + n * b)
	else:
		zero = x.split('0')
		one = x.split('1')
		count = 0
		for k in zero:
			if k != '':
				count += 1
		for ll in one:
			if ll != '':
				count += 1
		if count < 3:
			print(a * n + b * count)
		else:
			print(a * n + b * (count // 2 + 1))


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations, accumulate
from math import gcd, floor, inf, log2, sqrt, log10
from bisect import bisect_right, bisect_left
from statistics import mode
from string import ascii_lowercase
cases = int(input())
for _ in range(cases):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		ans = n * (a + b)
	else:
		cnt = 0
		for (i, grp) in groupby(s):
			cnt += 1
		cnt = cnt // 2 + 1
		ans = n * a + cnt * b
	print(ans)


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

def solve():
	(n, a, b) = readline()
	s = input()
	if b > 0:
		print(n * (a + b))
	else:
		print(n * a + max(s.count('01'), s.count('10')) * b + b)

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


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
r = 1
while r <= T:
	(n, a, b) = map(int, input().split())
	s = input()
	seq = []
	conse = 1
	for i in range(1, n):
		if s[i] == s[i - 1]:
			conse += 1
		else:
			seq.append(conse)
			conse = 1
	seq.append(conse)
	ans = a * n
	if b >= 0:
		ans += b * n
	else:
		ans += b * (len(seq) // 2 + 1)
	print(ans)
	r += 1


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	ans0 = n * b + n * a
	cnt = 0
	for i in range(1, n):
		if s[i - 1] != s[i]:
			cnt += 1
	print(max((cnt + 3) // 2 * b + n * a, ans0))


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
MOD = 10 ** 9 + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

def main():
	for _ in range(int(input())):
		(n, a, b) = map(int, input().split())
		s = input()
		if b >= 0:
			print(n * a + n * b)
			continue
		seg = 1
		for i in range(n - 1):
			if s[i] != s[i + 1]:
				seg += 1
		print(n * a + b * (seg // 2 + 1))
main()


def main():
	from sys import stdin, setrecursionlimit
	input = stdin.buffer.readline
	for _ in range(int(input())):
		(n, a, b) = map(int, input().split())
		s = input()
		c = 1
		for i in range(n - 1):
			c += s[i] != s[i + 1]
		print(a * n + b * (n if b > 0 else c // 2 + 1))
main()


import math

def max_together(s):
	a = s[0]
	c = 0
	flag = 0
	for i in s:
		if i == a:
			flag = 0
		elif i != a and flag == 0:
			c += 1
			flag = 1
	return c + 1
test = int(input())
for _ in range(test):
	(n, a, b) = map(int, input().split(' '))
	s = input()
	n_cost = (a + b) * n
	o_cost = a * n + b * max_together(s)
	print(max(n_cost, o_cost))


t = int(input())
ans = []
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		ans.append(str((a + b) * n))
		continue
	s += '!'
	sum = 0
	for i in range(n):
		if s[i] != s[i + 1]:
			sum += 1
	ans.append(str(a * n + b * (sum // 2 + 1)))
print('\n'.join(ans))


import math
for i in range(int(input())):
	(n, a, b) = list(map(int, input().split()))
	s = list(input())
	c = 1
	ones = s.count('1')
	zeroes = s.count('0')
	a1 = []
	a0 = []
	i = 1
	while i < n:
		if s[i] == s[i - 1]:
			c += 1
		else:
			if s[i - 1] == '1':
				a1.append(c)
			else:
				a0.append(c)
			c = 1
		i += 1
	if s[n - 1] == '1':
		a1.append(c)
	else:
		a0.append(c)
	sum1 = 0
	for l in a0:
		sum1 += max((a + b) * l, a * l + b)
	if ones != 0:
		sum1 += max((a + b) * ones, a * ones + b)
	sum2 = 0
	for l in a1:
		sum2 += max((a + b) * l, a * l + b)
	if zeroes != 0:
		sum2 += max((a + b) * zeroes, a * zeroes + b)
	print(max(sum1, sum2))


def solve():
	(n, a, b) = map(int, input().split())
	binary = list(input())
	ans = 0
	if b >= 0:
		ans = len(binary) * a + b * len(binary)
	else:
		lst = []
		temp_str = binary[0]
		temp = binary[0]
		for i in range(1, len(binary)):
			if binary[i] == temp:
				temp_str += binary[i]
			else:
				lst.append(temp_str)
				temp = binary[i]
				temp_str = binary[i]
		lst.append(temp_str)
		ans = a * len(binary) + b * (len(lst) // 2 + 1)
	print(ans)
for i in range(int(input())):
	solve()


t = int(input())
for tc in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	ok = 0
	ct = 1
	for i in range(0, len(s) - 1):
		if s[i] != s[i + 1]:
			ct += 1
	val = ct // 2 + 1
	print(max(n * a + val * b, n * a + n * b))


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		ans = (a + b) * n
	else:
		nz = 0
		no = 0
		z = 0
		while z < n:
			if s[z] == '0':
				while z < n and s[z] == '0':
					z += 1
				nz += 1
			else:
				while z < n and s[z] == '1':
					z += 1
				no += 1
		ans = n * a + min(nz + 1, no + 1) * b
	print(ans)


from math import *
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	count = 0
	sym = 'X'
	for i in range(n):
		if s[i] != sym:
			sym = s[i]
			count += 1
	count = ceil((count + 1) / 2)
	if b >= 0:
		print(n * (a + b))
	else:
		print(n * a + count * b)


T = int(input())
while T > 0:
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	if b >= 0:
		ans = n * (a + b)
	else:
		run_zero = 0
		run_one = 0
		zero = 0
		one = 0
		if s[0] == '0':
			zero = 1
			run_zero = 1
		else:
			one = 1
			run_one = 1
		for i in range(1, n):
			if s[i] == '0' and zero == 1:
				continue
			elif s[i] == '0' and zero == 0:
				run_zero += 1
				zero = 1
				one = 0
			elif s[i] == '1' and one == 1:
				continue
			elif s[i] == '1' and one == 0:
				run_one += 1
				one = 1
				zero = 0
		ans = a * n + (min(run_one, run_zero) + 1) * b
	print(ans)
	T -= 1


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print(n * a + n * b)
	else:
		c = 1
		x = s[0]
		v = True
		for i in range(n):
			if s[i] == x:
				continue
			else:
				c = c + 1
				x = s[i]
		k = c // 2
		print(n * a + (k + 1) * b)


def numOfBlocks(s, n):
	if n == 1:
		return 1
	else:
		b = 1
		for i in range(len(s) - 1):
			if s[i] != s[i + 1]:
				b += 1
		return b
tcs = int(input())
for i in range(tcs):
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	m = numOfBlocks(s, n)
	if b > 0:
		print(a * n + b * n)
	else:
		print(a * n + (int(m / 2) + 1) * b)


def ans(n, a, b, s):
	if b >= 0:
		return n * (a + b)
	n_1 = 0
	n_0 = 0
	x = s[0]
	if x == '0':
		flag = 0
	else:
		flag = 1
	z = 0
	switch = 1
	for i in range(1, n):
		if flag == 0 and s[i] == '1':
			flag = 1
			switch += 1
		elif flag == 1 and s[i] == '0':
			flag = 0
			switch += 1
	if switch % 2 == 0:
		switch += 1
	z = a * n + (switch + 1) // 2 * b
	return z
m = int(input())
for i in range(m):
	arr = input().split()
	n = int(arr[0])
	a = int(arr[1])
	b = int(arr[2])
	s = input()
	print(ans(n, a, b, s))


I = input
exec(int(I()) * "n,a,b=map(int,I().split());s=x,*_=I();print(a*n+b*(n,s.count(x+'01'[x<'1'])+1)[b<0]);")


from math import floor
t = int(input())
for _ in range(t):
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	if b >= 0:
		print(a * len(s) + b * len(s))
	else:
		changes = [0]
		current = s[0]
		for i in range(1, n):
			if s[i] != current:
				current = s[i]
				changes.append(i)
		print(a * len(s) + floor(len(changes) / 2 + 1) * b)


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	c = 0
	i = 0
	while i < n:
		z = s[i]
		while s[i] == z:
			i = i + 1
			if i == n:
				break
		c = c + 1
	ans = max(a * n + b * n, a * n + c * b, a * n + (c // 2 + 1) * b)
	print(ans)


def solve(s):
	seen = s[0]
	ans = s[0]
	for i in s[1:]:
		if i != seen:
			ans += i
			seen = i
	return len(ans)
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	m = solve(s)
	ans = n * a + max(n * b, (m // 2 + 1) * b)
	print(ans)


for t in range(int(input())):
	z = input().split()
	n = int(z[0])
	a = int(z[1])
	b = int(z[2])
	s = input()
	if b > 0:
		print(n * (a + b))
	else:
		flip = 0
		for j in range(n - 1):
			if s[j] != s[j + 1]:
				flip += 1
		print(a * n + b * (1 + flip // 2 + flip % 2))


for i in range(int(input())):
	(n, a, b) = map(int, input().split())
	l = input()
	if b > 0:
		print(n * (a + b))
	else:
		flag = 'none'
		zero = 0
		one = 0
		s = 0
		for i in l:
			if int(i) + s == s and flag != 'zero':
				zero += 1
				flag = 'zero'
			elif int(i) + s != s and flag != 'one':
				one += 1
				flag = 'one'
		m = min(zero, one) + 1
		print(n * a + b * m)


for _ in range(int(input())):
	(n, a, b) = [int(i) for i in input().split()]
	s = [int(i) for i in input()]
	if b >= 0:
		print(n * (a + b))
	else:
		count = [0, 0]
		last = -1
		for i in s:
			if i != last:
				count[i] += 1
				last = i
		print(n * a + (min(count) + 1) * b)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b < 0:
		gp0 = s.count('10') + (s[0] == '0')
		gp1 = s.count('01') + (s[0] == '1')
		ops = min(gp0, gp1) + 1
		print(a * n + b * ops)
	else:
		print(a * n + b * n)


def count_blocks(line):
	current = line[0]
	blocks = 1
	for _symbol in line:
		if _symbol != current:
			blocks += 1
			current = _symbol
	return blocks
n = int(input())
for _ in range(n):
	(n, a, b) = map(int, input().split())
	line = input()
	if b > 0:
		answer = n * (a + b)
	else:
		answer = a * n + b * (1 + count_blocks(line) // 2)
	print(str(answer))


n = int(input())
res = []
for x in range(n):
	(s, a, b) = list(map(int, input().split()))
	string = input()
	if b >= 0:
		res.append(a * s + b * s)
	else:
		cnt = 0
		if string[0] == '0':
			cnt = string.count('01')
		else:
			cnt = string.count('10')
		res.append(a * s + b * (cnt + 1))
for x in res:
	print(x)


t = int(input())
for _ in range(t):
	s = input().split()
	(n, a, b) = (int(s[0]), int(s[1]), int(s[2]))
	bits = input()
	res = a * n
	if b >= 0:
		print(res + b * n)
	else:
		d = {0: 0, 1: 0}
		prev = None
		for i in bits:
			if i == '1':
				if prev == None or prev == '0':
					d[1] += 1
			elif prev == None or prev == '1':
				d[0] += 1
			prev = i
		print(res + (min(d[0], d[1]) + 1) * b)


t = int(input())
for i in range(t):
	count = 0
	(n, a, b) = map(int, input().split())
	f = input()
	lz = f[0]
	count = 1
	for z in f:
		if z != lz:
			count += 1
			lz = z
	print(max(n * (a + b), a * n + b * (count // 2 + 1)))


def countMax(s):
	if len(s) == 1:
		return 1
	else:
		res = 1
		for i in range(1, len(s)):
			if s[i] != s[i - 1]:
				res += 1
		if s[0] == s[-1]:
			return (res + 1) // 2
		else:
			return res // 2 + 1
t = int(input())
for i in range(t):
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	if a == 0:
		if b <= 0:
			print(b * countMax(s))
		else:
			print(b * n)
	elif a < 0:
		if b < 0:
			print(a * n + b * countMax(s))
		elif b == 0:
			print(a * n)
		else:
			print(a * n + b * n)
	elif b < 0:
		print(a * n + b * countMax(s))
	elif b == 0:
		print(a * n)
	else:
		print(a * n + b * n)


import math
nt = int(input())
ans = []

def soln(s, n, a, b):
	ones = 0
	zeros = 0
	if s[-1] == '1':
		ones = 1
	else:
		zeros = 1
	for x in range(n - 1):
		if s[x] == '0' and s[x + 1] == '1':
			zeros = zeros + 1
		if s[x] == '1' and s[x + 1] == '0':
			ones = ones + 1
	if b < 0:
		return a * n + (min(ones, zeros) + 1) * b
	else:
		return n * (a + b)
for x in range(nt):
	inp = list(map(int, input().split()))
	n = inp[0]
	a = inp[1]
	b = inp[2]
	s = input()
	ans.append(soln(list(s), n, a, b))
for x in ans:
	print(x)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	x = list((i for i in s.split('0') if len(i)))
	y = list((i for i in s.split('1') if len(i)))
	print(n * a + max(n * b, ((len(x) + len(y)) // 2 + 1) * b))


def ints():
	return map(int, input().split())
T = int(input())
for _ in range(T):
	(n, a, b) = ints()
	s = input()
	p = a * n
	if b >= 0:
		p += b * n
	else:
		while s:
			ns = s.strip('0')
			if len(ns) != len(s):
				p += b
			s = ns
			if not s:
				break
			ns = s.strip('1')
			if len(ns) != len(s):
				p += b
			s = ns
	print(p)


for iii in range(int(input())):
	(n, a, b) = map(int, input().split())
	q = input()
	if b >= 0:
		x = n * (a + b)
		print(x)
	else:
		cout = 1
		x = q[0]
		for i in range(1, n):
			if x != q[i]:
				cout += 1
				x = q[i]
		print(n * a + (cout // 2 + 1) * b)


from math import sqrt
t = int(input())
for jeshdv in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	if b > 0:
		print((b + a) * n)
	else:
		sum = 0
		cnt = 0
		i = 0
		while i < n:
			if s[i] != s[0]:
				j = i
				while s[j] != s[0]:
					j += 1
					if j > n - 1:
						break
				sum += (j - i) * a + b
				i = j - 1
			else:
				cnt += 1
			i += 1
		print(sum + cnt * a + b)


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


t = int(input())
for _ in range(t):
	(l, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		total = (a + b) * l
	else:
		z = s.count('01')
		o = s.count('10')
		m = max(z, o) + 1
		total = a * l + b * m
	print(total)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print((a + b) * n)
	else:
		z1 = s.count('01')
		z2 = s.count('10')
		z = max(z1, z2) + 1
		print(n * a + b * z)


t = int(input())
for i in range(t):
	(n, a, b) = list(map(int, input().strip().split()))
	s = input()
	breaks = 0
	for i in range(n - 1):
		if s[i] != s[i + 1]:
			breaks += 1
	if b >= 0:
		print(a * n + b * n)
	elif b < 0:
		if breaks % 2 == 0:
			print(a * n + b * (breaks // 2 + 1))
		else:
			print(a * n + b * (breaks // 2 + 2))


def total_groups(s):
	prev = ''
	count = 0
	for i in s:
		if i != prev:
			prev = i
			count += 1
	return count
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print(n * (a + b))
	else:
		print(n * a + b * (total_groups(s) // 2 + 1))


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input().strip()
	ans = a * n
	if b >= 0:
		ans += b * n
	else:
		prev = '-'
		segs = 0
		for c in s:
			if c != prev:
				segs += 1
			prev = c
		ans += b * (segs // 2 + 1)
	print(ans)


def solve():
	(n, a, b) = map(int, input().split())
	s = input()
	li = []
	for i in s:
		if i == '1':
			li.append(1)
		else:
			li.append(0)
	if b >= 0:
		print(n * (a + b))
	else:
		i = 0
		j = 0
		ans = 0
		temp = []
		if li[0] == 1:
			while i < n and j < n:
				if li[i] == li[j]:
					j += 1
				else:
					if li[i] == 0:
						temp.append(j - i)
					i = j
					j = i + 1
			if li[i] == 0:
				temp.append(j - i)
			ans += n * a + (len(temp) + 1) * b
			print(ans)
		else:
			while i < n and j < n:
				if li[i] == li[j]:
					j += 1
				else:
					if li[i] == 1:
						temp.append(j - i)
					i = j
					j = i + 1
			if li[i] == 1:
				temp.append(j - i)
			ans += n * a + (len(temp) + 1) * b
			print(ans)
t = int(input())
for _ in range(t):
	solve()


for t in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	changes = 0
	for i in range(1, n):
		if s[i] != s[i - 1]:
			changes += 1
	min_moves = (changes + 3) // 2
	if b >= 0:
		print(n * (a + b))
		continue
	print(n * a + min_moves * b)


def naiveSolve():
	return

def flip(s):
	s2 = []
	for c in s:
		if c == '0':
			s2.append('1')
		else:
			s2.append('0')
	return s2

def remove0First(s, a, b):
	ans = 0
	l = 0
	oneCnt = 0
	for c in s:
		if c == '0':
			l += 1
		else:
			if l > 0:
				ans += a * l + b
			l = 0
			oneCnt += 1
	if l > 0:
		ans += a * l + b
	if oneCnt > 0:
		ans += a * oneCnt + b
	return ans

def main():
	t = int(input())
	allans = []
	for _ in range(t):
		(n, a, b) = readIntArr()
		s = input()
		ans = (a + b) * n
		ans = max(ans, remove0First(s, a, b))
		ans = max(ans, remove0First(flip(s), a, b))
		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(l, r):
	print('? {} {}'.format(l, r))
	sys.stdout.flush()
	return int(input())

def answerInteractive(x):
	print('! {}'.format(x))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
from math import gcd, floor, ceil
for _abc in range(1):
	main()


def count(string, length):
	res = 1
	for i in range(1, length):
		if string[i] != string[i - 1]:
			res += 1
	return res // 2 + 1
t = int(input())
for case in range(t):
	line = [int(x) for x in input().split()]
	if line[2] >= 0:
		input()
		print(line[0] * (line[1] + line[2]))
	else:
		print(line[0] * line[1] + line[2] * count(input(), line[0]))


t = int(input())
for i in range(t):
	(n, a, b) = tuple(map(int, input().split()))
	s = str(input())
	sm = a * n
	count = 1
	if b > 0:
		sm += b * n
	else:
		for j in range(1, n):
			if s[j] != s[j - 1]:
				count += 1
		sm += (count // 2 + 1) * b
	print(sm)


import sys
input = sys.stdin.readline
import re
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()[:-1]
	if b >= 0:
		print(n * (a + b))
	else:
		x = re.sub('1+', 'b', re.sub('0+', 'a', s))
		y = min(x.count('a'), x.count('b')) + 1
		print(y * b + a * n)


def calc():
	count = 1
	(n, a, b) = [int(num) for num in input().split(' ')]
	s = input()
	for i in range(1, n):
		if s[i] != s[i - 1]:
			count += 1
	count = count // 2 + 1
	if b >= 0:
		return (a + b) * n
	else:
		return a * n + b * count
test_count = int(input())
for i in range(test_count):
	print(calc())


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print(n * (a + b))
	else:
		(z, o) = (0, 0)
		if s[0] == '1':
			o += 1
		else:
			z += 1
		for i in range(1, n):
			if s[i] == s[i - 1]:
				continue
			elif s[i] == '1':
				o += 1
			else:
				z += 1
		print(n * a + (min(z, o) + 1) * b)


import os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right
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')
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print((a + b) * n)
	else:
		z = o = 0
		if s[0] == '1':
			o += 1
		else:
			z += 1
		for i in range(1, n):
			if s[i] != s[i - 1]:
				if s[i] == '1':
					o += 1
				else:
					z += 1
		print(a * n + (min(z, o) + 1) * b)


def maxCost(n, a, b, st):
	count = 1
	for i in range(n - 1):
		if st[i] != st[i + 1]:
			count += 1
	if b >= 0:
		return a * n + b * n
	elif b < 0:
		if count % 2 == 1:
			return int(a * n + b * (count + 1) / 2)
		elif count % 2 == 0:
			return int(a * n + b * (count + 2) / 2)
arr = []
for i in range(int(input())):
	(n, a, b) = input().split()
	st = input()
	arr.append(maxCost(int(n), int(a), int(b), st))
for i in arr:
	print(i)


trails = int(input())
answer_list = []
for x in range(trails):
	numbers = input().split(' ')
	string = input()
	lenth = int(numbers[0])
	a = int(numbers[1])
	b = int(numbers[2])
	answer = 0
	if b > 0 or b == 0:
		answer = lenth * (a + b)
	else:
		answer += lenth * a
		num_0 = 0
		num_1 = 0
		prev = string[0]
		for d in string:
			if d != prev:
				if prev == '1':
					num_1 += 1
				else:
					num_0 += 1
			prev = d
		if prev == '1':
			num_1 += 1
		else:
			num_0 += 1
		if num_0 < num_1:
			answer += b * num_0 + b
		else:
			answer += b * num_1 + b
	answer_list.append(answer)
for g in answer_list:
	print(g)


def max_cost_deletion(n, a, b, string):
	points = 0
	if b >= 0:
		points += n * a + n * b
	elif b < 0:
		count = 1
		for i in range(1, len(string)):
			if string[i] != string[i - 1]:
				count += 1
		points += n * a + (count // 2 + 1) * b
	return points
t = int(input())
for i in range(t):
	(n, a, b) = input().split()
	(n, a, b) = (int(n), int(a), int(b))
	string = input()
	print(max_cost_deletion(n, a, b, string))


from sys import stdin
input = stdin.readline
rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
for _ in range(rn()):
	(n, a, b) = rns()
	s = rs()
	c = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			c += 1
	ans = max(n * a + n * b, n * a + (c // 2 + 1) * b)
	print(ans)


import sys

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

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

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

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	(n, a, b) = invr()
	str_1 = input()
	len_1 = len(str_1)
	if b > 0:
		print((a + b) * len_1)
		continue
	if a <= 0 and b >= 0:
		print((a + b) * len_1)
	else:
		k = []
		flag = 1
		for j in range(len_1):
			if len_1 == 1:
				k.append(1)
				break
			if j == 0:
				continue
			if str_1[j] == str_1[j - 1]:
				flag = flag + 1
			else:
				k.append(flag)
				flag = 1
			if j == len_1 - 1:
				k.append(flag)
		print(len_1 * a + (int(len(k) / 2) + 1) * b)


for t in range(int(input())):
	L = [int(x) for x in input().split()]
	n = L[0]
	a = L[1]
	b = L[2]
	s = input()
	pts = 0
	if b >= 0:
		print((a + b) * n)
	else:
		L1 = s.split('0')
		ch = ' '.join(L1)
		L1 = ch.split()
		L0 = s.split('1')
		ch = ' '.join(L0)
		L0 = ch.split()
		if len(L0) > len(L1):
			pts += a * n + b * (len(L1) + 1)
		else:
			pts += a * n + b * (len(L0) + 1)
		print(pts)


mod = 1000000007
from math import factorial, ceil, pow, sqrt
from sys import stdin, stdout
from collections import defaultdict, Counter, deque
for _ in range(int(stdin.readline())):
	(n, a, b) = map(int, stdin.readline().split())
	s = stdin.readline().strip('\n')
	ans = list(s.split('1'))
	li = list(s.split('0'))
	x = []
	y = []
	for ele in ans:
		if ele != '':
			x.append(ele)
	for ele in li:
		if ele != '':
			y.append(ele)
	p = a * n + b * min(len(x) + 1, len(y) + 1)
	t = (a + b) * n
	print(max(t, p))


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	c = 0
	s1 = ''
	for i in s:
		if i != s1:
			c += 1
			s1 = i
	n1 = c // 2 + 1
	print(n * a + max(n1 * b, n * b))


for t in range(int(input())):
	n = input().split()
	n = [int(x) for x in n]
	(n, a, b) = n
	s = input()
	s1 = s.split('0')
	s1 = [x for x in s1 if x]
	s2 = s.split('1')
	s2 = [x for x in s2 if x]
	times = int(len(s1 + s2) / 2) + 1
	if a > 0 and b > 0:
		print((a + b) * len(s))
	elif a < 0 and b < 0:
		print(a * len(s) + b * times)
	elif a > 0 and b < 0:
		print(a * len(s) + b * times)
	elif a < 0 and b > 0:
		print(a * len(s) + b * len(s))
	elif b == 0 and a != 0:
		print(a * len(s))
	elif a == 0 and b != 0:
		if b > 0:
			ans = b * len(s)
		else:
			ans = b * times
		print(ans)
	elif a == 0 and b == 0:
		print(0)


def deletion(n, a, b, l):
	if b >= 0:
		return (a + b) * n
	else:
		m = []
		iorg = 0
		x = l[iorg]
		count = 0
		for i in range(0, n, 1):
			if l[i] == x:
				count = count + 1
			else:
				m.append((x, iorg, count))
				iorg = i
				x = l[iorg]
		m.append((x, iorg, count))
		return a * n + b * (len(m) // 2 + 1)
x = int(input())
m = []
for i in range(x):
	y = input()
	z = input()
	y1 = y.split(' ')
	y2 = [int(t) for t in y1]
	m.append((y2, z))
for j in range(x):
	print(deletion(m[j][0][0], m[j][0][1], m[j][0][2], m[j][1]))


t = int(input())
for _ in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print(a * n + b * n)
		continue
	v = list((ord(i) for i in s))
	tot = 1
	for i in range(1, n):
		if v[i] != v[i - 1]:
			tot += 1
	print((tot // 2 + 1) * b + n * a)


import math
k = int(input())
while k:
	k -= 1
	(n, a, b) = map(int, input().split())
	arr = input()
	if b >= 0:
		print((a + b) * n)
		continue
	else:
		arr1 = arr.split('0')
		arr2 = arr.split('1')
		cnt1 = cnt2 = 0
		for item in arr1:
			if item:
				cnt1 += 1
		for item in arr2:
			if item:
				cnt2 += 1
		ans = a * n + max((cnt1 + 1) * b, (cnt2 + 1) * b)
		print(ans)


def divisors(M):
	d = []
	i = 1
	while M >= i ** 2:
		if M % i == 0:
			d.append(i)
			if i ** 2 != M:
				d.append(M // i)
		i = i + 1
	return d

def popcount(x):
	x = x - (x >> 1 & 1431655765)
	x = (x & 858993459) + (x >> 2 & 858993459)
	x = x + (x >> 4) & 252645135
	x = x + (x >> 8)
	x = x + (x >> 16)
	return x & 127

def eratosthenes(n):
	res = [0 for i in range(n + 1)]
	prime = set([])
	for i in range(2, n + 1):
		if not res[i]:
			prime.add(i)
			for j in range(1, n // i + 1):
				res[i * j] = 1
	return prime

def factorization(n):
	res = []
	for p in prime:
		if n % p == 0:
			while n % p == 0:
				n //= p
			res.append(p)
	if n != 1:
		res.append(n)
	return res

def euler_phi(n):
	res = n
	for x in range(2, n + 1):
		if x ** 2 > n:
			break
		if n % x == 0:
			res = res // x * (x - 1)
			while n % x == 0:
				n //= x
	if n != 1:
		res = res // n * (n - 1)
	return res

def ind(b, n):
	res = 0
	while n % b == 0:
		res += 1
		n //= b
	return res

def isPrimeMR(n):
	d = n - 1
	d = d // (d & -d)
	L = [2, 3, 5, 7, 11, 13, 17]
	for a in L:
		t = d
		y = pow(a, t, n)
		if y == 1:
			continue
		while y != n - 1:
			y = y * y % n
			if y == 1 or t == n - 1:
				return 0
			t <<= 1
	return 1

def findFactorRho(n):
	from math import gcd
	m = 1 << n.bit_length() // 8
	for c in range(1, 99):
		f = lambda x: (x * x + c) % n
		(y, r, q, g) = (2, 1, 1, 1)
		while g == 1:
			x = y
			for i in range(r):
				y = f(y)
			k = 0
			while k < r and g == 1:
				ys = y
				for i in range(min(m, r - k)):
					y = f(y)
					q = q * abs(x - y) % n
				g = gcd(q, n)
				k += m
			r <<= 1
		if g == n:
			g = 1
			while g == 1:
				ys = f(ys)
				g = gcd(abs(x - ys), n)
		if g < n:
			if isPrimeMR(g):
				return g
			elif isPrimeMR(n // g):
				return n // g
			return findFactorRho(g)

def primeFactor(n):
	i = 2
	ret = {}
	rhoFlg = 0
	while i * i <= n:
		k = 0
		while n % i == 0:
			n //= i
			k += 1
		if k:
			ret[i] = k
		i += 1 + i % 2
		if i == 101 and n >= 2 ** 20:
			while n > 1:
				if isPrimeMR(n):
					(ret[n], n) = (1, 1)
				else:
					rhoFlg = 1
					j = findFactorRho(n)
					k = 0
					while n % j == 0:
						n //= j
						k += 1
					ret[j] = k
	if n > 1:
		ret[n] = 1
	if rhoFlg:
		ret = {x: ret[x] for x in sorted(ret)}
	return ret

def divisors(n):
	res = [1]
	prime = primeFactor(n)
	for p in prime:
		newres = []
		for d in res:
			for j in range(prime[p] + 1):
				newres.append(d * p ** j)
		res = newres
	res.sort()
	return res

def xorfactorial(num):
	if num == 0:
		return 0
	elif num == 1:
		return 1
	elif num == 2:
		return 3
	elif num == 3:
		return 0
	else:
		x = baseorder(num)
		return 2 ** x * ((num - 2 ** x + 1) % 2) + function(num - 2 ** x)

def xorconv(n, X, Y):
	if n == 0:
		res = [X[0] * Y[0] % mod]
		return res
	x = [X[i] + X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	y = [Y[i] + Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	z = [X[i] - X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	w = [Y[i] - Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	res1 = xorconv(n - 1, x, y)
	res2 = xorconv(n - 1, z, w)
	former = [(res1[i] + res2[i]) * inv for i in range(2 ** (n - 1))]
	latter = [(res1[i] - res2[i]) * inv for i in range(2 ** (n - 1))]
	former = list(map(lambda x: x % mod, former))
	latter = list(map(lambda x: x % mod, latter))
	return former + latter

def merge_sort(A, B):
	(pos_A, pos_B) = (0, 0)
	(n, m) = (len(A), len(B))
	res = []
	while pos_A < n and pos_B < m:
		(a, b) = (A[pos_A], B[pos_B])
		if a < b:
			res.append(a)
			pos_A += 1
		else:
			res.append(b)
			pos_B += 1
	res += A[pos_A:]
	res += B[pos_B:]
	return res

class UnionFindVerSize:

	def __init__(self, N):
		self._parent = [n for n in range(0, N)]
		self._size = [1] * N
		self.group = N

	def find_root(self, x):
		if self._parent[x] == x:
			return x
		self._parent[x] = self.find_root(self._parent[x])
		stack = [x]
		while self._parent[stack[-1]] != stack[-1]:
			stack.append(self._parent[stack[-1]])
		for v in stack:
			self._parent[v] = stack[-1]
		return self._parent[x]

	def unite(self, x, y):
		gx = self.find_root(x)
		gy = self.find_root(y)
		if gx == gy:
			return
		self.group -= 1
		if self._size[gx] < self._size[gy]:
			self._parent[gx] = gy
			self._size[gy] += self._size[gx]
		else:
			self._parent[gy] = gx
			self._size[gx] += self._size[gy]

	def get_size(self, x):
		return self._size[self.find_root(x)]

	def is_same_group(self, x, y):
		return self.find_root(x) == self.find_root(y)

class WeightedUnionFind:

	def __init__(self, N):
		self.parent = [i for i in range(N)]
		self.size = [1 for i in range(N)]
		self.val = [0 for i in range(N)]
		self.flag = True
		self.edge = [[] for i in range(N)]

	def dfs(self, v, pv):
		stack = [(v, pv)]
		new_parent = self.parent[pv]
		while stack:
			(v, pv) = stack.pop()
			self.parent[v] = new_parent
			for (nv, w) in self.edge[v]:
				if nv != pv:
					self.val[nv] = self.val[v] + w
					stack.append((nv, v))

	def unite(self, x, y, w):
		if not self.flag:
			return
		if self.parent[x] == self.parent[y]:
			self.flag = self.val[x] - self.val[y] == w
			return
		if self.size[self.parent[x]] > self.size[self.parent[y]]:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[x] += self.size[y]
			self.val[y] = self.val[x] - w
			self.dfs(y, x)
		else:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[y] += self.size[x]
			self.val[x] = self.val[y] + w
			self.dfs(x, y)

class Dijkstra:

	class Edge:

		def __init__(self, _to, _cost):
			self.to = _to
			self.cost = _cost

	def __init__(self, V):
		self.G = [[] for i in range(V)]
		self._E = 0
		self._V = V

	@property
	def E(self):
		return self._E

	@property
	def V(self):
		return self._V

	def add_edge(self, _from, _to, _cost):
		self.G[_from].append(self.Edge(_to, _cost))
		self._E += 1

	def shortest_path(self, s):
		import heapq
		que = []
		d = [10 ** 15] * self.V
		d[s] = 0
		heapq.heappush(que, (0, s))
		while len(que) != 0:
			(cost, v) = heapq.heappop(que)
			if d[v] < cost:
				continue
			for i in range(len(self.G[v])):
				e = self.G[v][i]
				if d[e.to] > d[v] + e.cost:
					d[e.to] = d[v] + e.cost
					heapq.heappush(que, (d[e.to], e.to))
		return d

def Z_algorithm(s):
	N = len(s)
	Z_alg = [0] * N
	Z_alg[0] = N
	i = 1
	j = 0
	while i < N:
		while i + j < N and s[j] == s[i + j]:
			j += 1
		Z_alg[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < N and k + Z_alg[k] < j:
			Z_alg[i + k] = Z_alg[k]
			k += 1
		i += k
		j -= k
	return Z_alg

class BIT:

	def __init__(self, n, mod=0):
		self.BIT = [0] * (n + 1)
		self.num = n
		self.mod = mod

	def query(self, idx):
		res_sum = 0
		mod = self.mod
		while idx > 0:
			res_sum += self.BIT[idx]
			if mod:
				res_sum %= mod
			idx -= idx & -idx
		return res_sum

	def update(self, idx, x):
		mod = self.mod
		while idx <= self.num:
			self.BIT[idx] += x
			if mod:
				self.BIT[idx] %= mod
			idx += idx & -idx
		return

class dancinglink:

	def __init__(self, n, debug=False):
		self.n = n
		self.debug = debug
		self._left = [i - 1 for i in range(n)]
		self._right = [i + 1 for i in range(n)]
		self.exist = [True for i in range(n)]

	def pop(self, k):
		if self.debug:
			assert self.exist[k]
		L = self._left[k]
		R = self._right[k]
		if L != -1:
			if R != self.n:
				(self._right[L], self._left[R]) = (R, L)
			else:
				self._right[L] = self.n
		elif R != self.n:
			self._left[R] = -1
		self.exist[k] = False

	def left(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._left[res]
			if res == -1:
				break
			k -= 1
		return res

	def right(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._right[res]
			if res == self.n:
				break
			k -= 1
		return res

class SparseTable:

	def __init__(self, A, merge_func, ide_ele):
		N = len(A)
		n = N.bit_length()
		self.table = [[ide_ele for i in range(n)] for i in range(N)]
		self.merge_func = merge_func
		for i in range(N):
			self.table[i][0] = A[i]
		for j in range(1, n):
			for i in range(0, N - 2 ** j + 1):
				f = self.table[i][j - 1]
				s = self.table[i + 2 ** (j - 1)][j - 1]
				self.table[i][j] = self.merge_func(f, s)

	def query(self, s, t):
		b = t - s + 1
		m = b.bit_length() - 1
		return self.merge_func(self.table[s][m], self.table[t - 2 ** m + 1][m])

class BinaryTrie:

	class node:

		def __init__(self, val):
			self.left = None
			self.right = None
			self.max = val

	def __init__(self):
		self.root = self.node(-10 ** 15)

	def append(self, key, val):
		pos = self.root
		for i in range(29, -1, -1):
			pos.max = max(pos.max, val)
			if key >> i & 1:
				if pos.right is None:
					pos.right = self.node(val)
					pos = pos.right
				else:
					pos = pos.right
			elif pos.left is None:
				pos.left = self.node(val)
				pos = pos.left
			else:
				pos = pos.left
		pos.max = max(pos.max, val)

	def search(self, M, xor):
		res = -10 ** 15
		pos = self.root
		for i in range(29, -1, -1):
			if pos is None:
				break
			if M >> i & 1:
				if xor >> i & 1:
					if pos.right:
						res = max(res, pos.right.max)
					pos = pos.left
				else:
					if pos.left:
						res = max(res, pos.left.max)
					pos = pos.right
			elif xor >> i & 1:
				pos = pos.right
			else:
				pos = pos.left
		if pos:
			res = max(res, pos.max)
		return res

def solveequation(edge, ans, n, m):
	x = [0] * m
	used = [False] * n
	for v in range(n):
		if used[v]:
			continue
		y = dfs(v)
		if y != 0:
			return False
	return x

	def dfs(v):
		used[v] = True
		r = ans[v]
		for (to, dire, id) in edge[v]:
			if used[to]:
				continue
			y = dfs(to)
			if dire == -1:
				x[id] = y
			else:
				x[id] = -y
			r += y
		return r

class SegmentTree:

	def __init__(self, init_val, segfunc, ide_ele):
		n = len(init_val)
		self.segfunc = segfunc
		self.ide_ele = ide_ele
		self.num = 1 << (n - 1).bit_length()
		self.tree = [ide_ele] * 2 * self.num
		self.size = n
		for i in range(n):
			self.tree[self.num + i] = init_val[i]
		for i in range(self.num - 1, 0, -1):
			self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

	def update(self, k, x):
		k += self.num
		self.tree[k] = x
		while k > 1:
			self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
			k >>= 1

	def query(self, l, r):
		if r == self.size:
			r = self.num
		res = self.ide_ele
		l += self.num
		r += self.num
		while l < r:
			if l & 1:
				res = self.segfunc(res, self.tree[l])
				l += 1
			if r & 1:
				res = self.segfunc(res, self.tree[r - 1])
			l >>= 1
			r >>= 1
		return res

	def bisect_l(self, l, r, x):
		l += self.num
		r += self.num
		Lmin = -1
		Rmin = -1
		while l < r:
			if l & 1:
				if self.tree[l] <= x and Lmin == -1:
					Lmin = l
				l += 1
			if r & 1:
				if self.tree[r - 1] <= x:
					Rmin = r - 1
			l >>= 1
			r >>= 1
		if Lmin != -1:
			pos = Lmin
			while pos < self.num:
				if self.tree[2 * pos] <= x:
					pos = 2 * pos
				else:
					pos = 2 * pos + 1
			return pos - self.num
		elif Rmin != -1:
			pos = Rmin
			while pos < self.num:
				if self.tree[2 * pos] <= x:
					pos = 2 * pos
				else:
					pos = 2 * pos + 1
			return pos - self.num
		else:
			return -1
import sys, random, bisect
from collections import deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations
from math import gcd, log
input = lambda : sys.stdin.readline().rstrip()
mi = lambda : map(int, input().split())
li = lambda : list(mi())
dp = [1 for i in range(301)]
dp[2] = 2
for i in range(3, 301):
	dp[i] = 1 + dp[i - 2]
for _ in range(int(input())):
	(n, a, b) = mi()
	s = input()
	cnt = 1
	for i in range(n - 1):
		if s[i] != s[i + 1]:
			cnt += 1
	if b < 0:
		print(a * n + b * dp[cnt])
	else:
		print(a * n + b * n)


def varr(k):
	u = 1
	u1 = k[0]
	for m in k:
		if m != u1:
			u += 1
		else:
			continue
		u1 = m
	if u == 1:
		return 1
	else:
		return u // 2 + 1
t = int(input())
for r in range(t):
	(n, a, b) = input().split()
	l = input()
	n = int(n)
	a = int(a)
	b = int(b)
	if b > 0:
		print((a + b) * n)
	else:
		print(a * n + varr(l) * b)


from collections import Counter, deque
from math import *

def solve():
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		ans = n * (a + b)
		print(ans)
		return
	one = []
	zero = []
	cur = s[0]
	ind = 0
	for i in range(n):
		if s[i] != cur:
			if s[i] == '1':
				zero.append([ind, i - 1])
				ind = i
			else:
				one.append([ind, i - 1])
				ind = i
			cur = s[i]
	if cur == '1':
		one.append([ind, n - 1])
	else:
		zero.append([ind, n - 1])
	n1 = len(one)
	n0 = len(zero)
	print(n * a + (min(n1, n0) + 1) * b)
for _ in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print(n * (a + b))
	else:
		sz = []
		flg = str(1 - int(s[0]))
		cnt = 0
		for j in range(n):
			if s[j] == flg:
				cnt += 1
			elif cnt > 0:
				sz.append(cnt)
				cnt = 0
		if cnt > 0:
			sz.append(cnt)
		sz.append(s.count(str(1 - int(flg))))
		v = sum(sz) - len(sz)
		print(n * (a + b) - v * b)


import sys
cnt = int(input())
for _ in range(cnt):
	(n, a, b) = map(int, input().strip().split())
	s = input().strip()
	if b >= 0:
		print((a + b) * n)
	else:
		sections = 1
		last = s[0]
		for c in s:
			if last != c:
				sections += 1
				last = c
		print(a * n + (sections // 2 + 1) * b)


t = int(input())
for i in range(t):
	(n, a, b) = [int(x) for x in input().split()]
	s = input()
	if b >= 0:
		res = (a + b) * n
	else:
		l1 = s.split('0')
		l0 = s.split('1')
		l11 = [x for x in l1 if x != '']
		l00 = [x for x in l0 if x != '']
		c1 = len(l11)
		c0 = len(l00)
		res = a * n + (min(c1, c0) + 1) * b
	print(res)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	if 2 * a + b > 2 * (a + b):
		i = 0
		ans1 = 0
		c = s.count('1')
		ans1 += c * a + b
		while i < n:
			if s[i] == '1':
				i += 1
				continue
			j = i + 1
			while j < n and s[j] == '0':
				j += 1
			ans1 += (j - i) * a + b
			i = j
		i = 0
		ans2 = 0
		c = s.count('0')
		ans2 += c * a + b
		while i < n:
			if s[i] == '0':
				i += 1
				continue
			j = i + 1
			while j < n and s[j] == '1':
				j += 1
			ans2 += (j - i) * a + b
			i = j
		print(max(ans1, ans2))
	else:
		print(n * (a + b))


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, a, b) = map(int, stdin.readline().split())
	s = [int(x) for x in input()]
	ans = a * n
	if b >= 0:
		ans += n * b
	else:
		count1 = 1 if s[0] else 0
		count0 = 0 if count1 else 1
		prev = s[0]
		for i in s[1:]:
			if i:
				if not prev:
					count1 += 1
			elif prev:
				count0 += 1
			prev = i
		ans += (min(count1, count0) + 1) * b
	print(ans)


t = int(input())
for j in range(t):
	(n, a, b) = map(int, input().split())
	ans1 = 0
	ans2 = 0
	s = input()
	ch = 0
	per = ''
	e = 0
	for i in range(n):
		if ch == 1 and per != s[i]:
			if per == '1':
				ans1 += max(a * e + b, a * e + e * b)
			else:
				ans2 += max(a * e + b, a * e + e * b)
			e = 0
			ch = 0
			per = s[i]
		if ch == 1 and per == s[i]:
			e += 1
		if ch == 0:
			per = s[i]
			ch = 1
			e += 1
	if e != 0:
		if per == '1':
			ans1 += max(a * e + b, a * e + e * b)
		else:
			ans2 += max(a * e + b, a * e + e * b)
	ed = s.count('1')
	nol = s.count('0')
	if ed == 0:
		print(max(ans1 + nol * a + b, ans1 + nol * a + b * nol, ans2))
	elif nol == 0:
		print(max(ans1, ans2 + ed * a + b, ans2 + ed * a + b * ed))
	else:
		print(max(ans1 + nol * a + b, ans1 + nol * a + b * nol, ans2 + ed * a + b, ans2 + ed * a + b * ed))


import re

def result():
	nab = list(map(int, input().split()))
	string = input()
	n = nab[0]
	a = nab[1]
	b = nab[2]
	if b < 0:
		regex = '0+'
		regex1 = '1+'
		ze = re.findall(regex, string)
		on = re.findall(regex1, string)
		zel = len(ze)
		onl = len(on)
		if zel >= onl:
			t = onl + 1
		else:
			t = zel + 1
		print(n * a + t * b)
	else:
		print((a + b) * n)
for i in range(int(input())):
	result()


import re
for _ in range(0, int(input())):
	(n, a, b) = map(int, input().split())
	v = input()
	oc = v.count('1')
	zc = len(v) - oc
	if b >= 0:
		print(b * n + a * n)
	else:
		m = len(re.findall('1+', v)) + len(re.findall('0+', v))
		print(a * n + b * (m // 2 + 1))


from os import path
from math import ceil
from sys import stdin, stdout
if path.exists('tc.txt'):
	stdin = open('tc.txt', 'r')

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

def gms():
	return map(str, stdin.readline().strip().split())

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

def gart():
	return tuple(map(int, stdin.readline().strip().split()))

def gars():
	return list(map(str, stdin.readline().strip().split()))

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

def gls():
	return list(stdin.readline().strip())

def gi():
	return int(stdin.readline())
tc = gi()
while tc:
	tc -= 1
	(n, a, b) = gmi()
	s = gs()
	temp = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			temp += 1
	if 0 <= b:
		ans = a * n + b * n
	else:
		ans = a * n + b * (temp // 2 + 1)
	print(ans)


import atexit, io, sys, collections, math, heapq, fractions, copy, os, functools
import sys
import random
import collections
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

def f(s, a, b):
	aa = len(s) * b
	stack = []
	for e in s:
		if len(stack) == 0 or e != stack[-1]:
			stack.append(e)
	cc = collections.Counter(stack)
	bb = 0
	nn = len(stack)
	while nn > 2:
		nn -= 2
		bb += 1
	bb += nn
	return a * len(s) + max(aa, bb * b)
	if len(s) == 0:
		return 0
	if s in mem:
		return mem[s]
	ans = -float('inf')
	i = 0
	for j in range(len(s)):
		if s[j] != s[i]:
			i = j
		recurse = f(s[:i] + s[j + 1:], a, b)
		cost = a * (j - i + 1) + b
		ans = max(ans, cost + recurse)
	mem[s] = ans
	return ans
for u in range(int(input())):
	mem = {}
	(n, a, b) = map(int, input().split())
	print(f(input(), a, b))


t = int(input())
for i in range(t):
	(n, a, b) = (int(l) for l in input().split())
	s = input()
	z = a * len(s)
	if b >= 0:
		z += b * len(s)
	else:
		q = s.count('10')
		p = s.count('01')
		z += b * (p + 1) * (p >= q) + b * (q + 1) * (p < q)
	print(z)


from typing import Counter
import sys
from collections import defaultdict as dd
from math import *

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

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

def sinp():
	return input()

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

def mod(f):
	return f % 1000000007

def pr(*x):
	print(*x)

def finp():
	f = open('input.txt', 'r')
	f = f.read().split('\n')
	return f

def finp():
	f = open('input.txt', 'r')
	f = f.read().split('\n')
	return f

def fout():
	return open('output.txt', 'w')

def fpr(f, x):
	f.write(x + '\n')

def csort(c):
	sorted(c.items(), key=lambda pair: pair[1], reverse=True)

def indc(l, n):
	c = {}
	for i in range(n):
		c[l[i]] = c.get(l[i], []) + [i + 1]
	return c
cou = inp()
for i in range(cou):
	(a, b, c) = vinp()
	s = sinp()
	(o, e) = (1, 1)
	if c >= 0:
		pr(a * (c + b))
	else:
		for i in range(a):
			if s[i] == '1' and s[i - 1] == '0':
				o += 1
			elif s[i] == '0' and s[i - 1] == '1':
				e += 1
		pr(b * a + c * min(o, e))


def solve():
	(n, a, b) = [int(x) for x in input().split()]
	s = list(input())
	if b > 0:
		return n * (a + b)
	(groups, prev) = (0, None)
	for i in s:
		if prev is None:
			groups = 1
		elif i == prev:
			continue
		else:
			groups += 1
		prev = i
	groups_of_one_color = groups // 2
	return n * a + b * (groups_of_one_color + 1)
for _ in range(int(input())):
	print(solve())


import sys
from math import *
import builtins
input = sys.stdin.readline

def print(x, end='\n'):
	sys.stdout.write(str(x) + end)

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

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

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

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

def print_iterable(p):
	print(' '.join(map(str, p)))

def binary_search(arr, x):
	low = 0
	high = len(arr) - 1
	mid = 0
	while low <= high:
		mid = (high + low) // 2
		if arr[mid] < x:
			low = mid + 1
		elif arr[mid] > x:
			high = mid - 1
		else:
			return mid
	return high

def main():
	t = get_int()
	for q in range(t):
		(n, a, b) = get_list_ints()
		ls = get_char_list()
		for i in range(n):
			ls[i] = int(ls[i])
		total = n * a
		if b >= 0:
			print(total + n * b)
		else:
			count = 0
			for i in range(n - 1):
				if ls[i] != ls[i + 1]:
					count += 1
			count += 1
			c = count // 2 + 1
			print(total + c * b)
	pass
main()


import sys
from math import ceil
t = int(input())
numbers = [str(x) for x in sys.stdin.read().split()]
for i in range(0, t):
	a = int(numbers[4 * i + 1])
	b = int(numbers[4 * i + 2])
	n = int(numbers[4 * i])
	x = numbers[4 * i + 3]
	if b >= 0:
		print(n * (a + b))
	else:
		cnt = 0
		binary = list(x)
		for j in range(0, n - 1):
			if binary[j] != binary[j + 1]:
				cnt += 1
			else:
				cnt += 0
		print(a * n + (ceil(cnt / 2) + 1) * b)


t = int(input())
res = []
for i in range(t):
	(n, a, b) = [int(i) for i in input().split()]
	s = input()
	count = 1
	for i in range(1, n):
		if s[i] != s[i - 1]:
			count += 1
	score = max(n * (a + b), n * a + (1 + count // 2) * b)
	res.append(score)
for el in res:
	print(el)


for _ in range(int(input())):
	(n, a, b) = map(int, input().split())
	(prev, cnt) = (0, 0)
	for c in input().rstrip():
		if c != prev:
			(prev, cnt) = (c, cnt + 1)
	cnt = cnt // 2 + 1
	if b < 0:
		print(n * a + cnt * b)
	else:
		print(n * (a + b))


t = int(input())
for i in range(t):
	(n, a, b) = map(int, input().split())
	s = input()
	if b >= 0:
		print((a + b) * n)
	else:
		seq = 0
		cnt = 0
		init_c = s[0]
		for c in s:
			if c != init_c:
				seq += 1
			elif seq > 0:
				cnt += 1
				seq = 0
		if s[-1] != init_c:
			cnt += 1
		print(a * n + b * (cnt + 1))


def blocks(s):
	currC = s[0]
	total_blocks = 1
	for c in s:
		if c != currC:
			total_blocks += 1
			currC = c
	return total_blocks
for t in range(int(input())):
	(n, a, b) = map(int, input().split())
	s = input()
	m = blocks(s)
	if b >= 0:
		print(n * (a + b))
	else:
		print(a * n + (m // 2 + 1) * b)