CF1440A.Buy the String

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Buy the String

You are given four integers nn, c0c_0, c1c_1 and hh and a binary string ss of length nn.

A binary string is a string consisting of characters 00 and 11.

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

After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character 00 you should pay c0c_0 coins, to buy the character 11 you should pay c1c_1 coins.

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

Input

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

The first line of the description of each test case contains four integers nn, c0c_{0}, c1c_{1}, hh (1n,c0,c1,h10001 \leq n, c_{0}, c_{1}, h \leq 1000).

The second line of the description of each test case contains the binary string ss of length nn.

Output

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

Note

In the first test case, you can buy all characters and pay 33 coins, because both characters 00 and 11 costs 11 coin.

In the second test case, you can firstly change 22-nd and 44-th symbols of the string from 11 to 00 and pay 22 coins for that. Your string will be 0000000000. After that, you can buy the string and pay 510=505 \cdot 10 = 50 coins for that. The total number of coins paid will be 2+50=522 + 50 = 52.

Samples

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

在线编程 IDE

建议全屏模式获得最佳体验