#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll T;
cin>>T;
while(T--){
ll n,a,b;
scanf("%lld%lld%lld",&n,&a,&b);
string s;
cin>>s;
ll ans=0;
ll node=0,cnt=0;
for(int i=0;i<n;i++){
if(s[i]=='0')
cnt++;
else
break;
}
if(cnt!=n)
ans=(cnt+1)*a+(cnt+2)*b;
else{
ans=(n+1)*b+n*a;
cout<<ans<<endl;
continue;
}
// cout<<ans<<endl;
ll cnt1=n-1;
for(int i=n-1;i>=cnt;i--){
if(s[i]=='0'){
cnt1--;
}
else
break;
}
ans+=(n-1-cnt1)*b+(n-cnt1)*a;
// cout<<ans<<endl;
ll sum=0;
for(int i=cnt;i<=cnt1;i++){
if(s[i]=='0')
sum++;
else{
if(sum==1){
ans+=a+2*b;
ans+=a+2*b;
sum=0;
continue;
}
if(sum==0){
ans+=a+2*b;
sum=0;
continue;
}
if((sum-1)*b>2*a){
ans+=(sum-1)*b;
ans+=(sum+2)*a;
ans+=2*b;
ans+=a+2*b;
}
else{
ans+=(sum+1)*a;
ans+=(sum+1)*2*b;
}
sum=0;
}
}
cout<<ans<<endl;
}
return 0;
}
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |