import java.util.*
import java.util.Collections.swap
import kotlin.math.*
import kotlin.system.exitProcess

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of int
private fun readLongs() = readStrings().map { it.toLong() } // list of long
private fun readDoubles() = readStrings().map { it.toDouble() } // list of long

fun Solve() {
    var (n, k1, k2) = readInts()
    var s = readLn()
    var a = ArrayList<Int>()
    var cur = 0
    for (c in s) {
        if (c == '1') {
            cur++
        }
        else if (cur > 0) {
            a.add(cur)
            cur = 0
        }
    }
    if (cur > 0) {
        a.add(cur)
    }
    var ans = 0
    for (i in a) {
        ans += k2 * (i / 2)
        if (i % 2 == 1) {
            ans += max(k1, k2 - k1)
        }
    }
    println(ans)
}

fun main() {
    var T = readInt()
    for (it in 1..T) {
       	Solve()
    }
}


import java.util.*
import java.util.Collections.swap
import kotlin.math.*
import kotlin.system.exitProcess

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of int
private fun readLongs() = readStrings().map { it.toLong() } // list of long
private fun readDoubles() = readStrings().map { it.toDouble() } // list of long

fun Solve() {
    var (n, k1, k2) = readInts()
    var s = readLn()
    var a = ArrayList<Int>()
    var cur = 0
    for (c in s) {
        if (c == '1') {
            cur++
        }
        else if (cur > 0) {
            a.add(cur)
            cur = 0
        }
    }
    if (cur > 0) {
        a.add(cur)
    }
    var ans = 0
    for (i in a) {
        ans += k2 * (i / 2)
        if (i % 2 == 1) {
            ans += k1
        }
    }
    println(ans)
}

fun main() {
    var T = readInt()
    for (it in 1..T) {
       	Solve()
    }
}


import java.util.*
import java.util.Collections.swap
import kotlin.math.*
import kotlin.system.exitProcess

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of int
private fun readLongs() = readStrings().map { it.toLong() } // list of long
private fun readDoubles() = readStrings().map { it.toDouble() } // list of long

fun Solve() {
    var (n, k1, k2) = readInts()
    var s = readLn()
    var a = ArrayList<Int>()
    var cur = 0
    for (c in s) {
        if (c == '1') {
            cur++
        }
        else if (cur > 0) {
            a.add(cur)
            cur = 0
        }
    }
    if (cur > 0) {
        a.add(cur)
    }
    var ans = 0
    for (i in a) {
        ans += min(k2, k1 + k1) * (i / 2)
        if (i % 2 == 1) {
            ans += k1
        }
    }
    println(ans)
}

fun main() {
    var T = readInt()
    for (it in 1..T) {
       	Solve()
    }
}


//package codeforces.kotlinheroes4

fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readLong() = readLn().toLong() // single long
fun readDouble() = readLn().toDouble() // single double
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints
fun readLongs() = readStrings().map { it.toLong() } // list of longs
fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main() {
    val times = readInt()
    repeat(times) {
        var sum = 0
        val (n, k1, k2) = readInts()
        val days = readLn()
        var i = 0
        var count = 0
        while (i < n) {
            if (i == n - 1) {
                if (days[i] == '1' && days[i - 1] == '0') sum += k1
            } else if (days[i] == '1') {
                ++count
                i++
                while (i < n && days[i] == '1') {
                    ++count
                    ++i
                }
                if (count >= 1) {
                    sum += ((count / 2) * k2)
                    sum += ((count % 2) * k1)
                    count = 0
                }
            }
            ++i
        }
        println(sum)
    }
}


package codeforces.kotlinheroes4

fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readLong() = readLn().toLong() // single long
fun readDouble() = readLn().toDouble() // single double
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints
fun readLongs() = readStrings().map { it.toLong() } // list of longs
fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun calculate(count: Int, k1: Int, k2: Int): Int = if (k2 >= k1 + k1) count * k1
else (count / 2) * k2 + (count % 2) * k1

fun main() {
    val times = readInt()
    repeat(times) {
        var sum = 0
        val (n, k1, k2) = readInts()
        var count = 0
        val days = readLn()

        for (c in days) {
            if (c == '0') {
                sum += calculate(count, k1, k2)
                count = 0
            } else {
                ++count
            }
        }
        sum += calculate(count, k1, k2)
        println(sum)
    }
}


//package codeforces.kotlinheroes4

fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readLong() = readLn().toLong() // single long
fun readDouble() = readLn().toDouble() // single double
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints
fun readLongs() = readStrings().map { it.toLong() } // list of longs
fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main() {
    val times = readInt()
    repeat(times) {
        var sum = 0
        val (n, k1, k2) = readInts()
        val days = readLn()
        var i = 0
        while (i < n) {
            if (i == n - 1) {
                if (days[i] == '1' && days[i - 1] == '0') sum += k1
            } else if (days[i] == '1' && days[i + 1] == '1') {
                sum += k2
                ++i
            } else if (days[i] == '1' && days[i + 1] == '0') {
                sum += k1
                ++i
            }
            ++i
        }
        println(sum)
    }
}


//package codeforces.kotlinheroes4

fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readLong() = readLn().toLong() // single long
fun readDouble() = readLn().toDouble() // single double
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints
fun readLongs() = readStrings().map { it.toLong() } // list of longs
fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main() {
    val times = readInt()
    repeat(times) {
        var sum = 0
        val (n, k1, k2) = readInts()
        val days = readLn()
        var i = 0
        var count = 0
        while (i < n) {
            if (i == n - 1) {
                if (days[i] == '1' && days[i - 1] == '0') sum += k1
            } else if (days[i] == '1') {
                ++count
                i++
                while (i < n && days[i] == '1') {
                    ++count
                    ++i
                }
                if (count >= 1) {
                    if (k2 >= k1 + k1) {
                        sum += (count * k1)
                    } else {
                        sum += ((count / 2) * k2)
                        sum += ((count % 2) * k1)
                        count = 0
                    }
                }
            }
            ++i
        }
        println(sum)
    }
}


//package codeforces.kotlinheroes4

fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readLong() = readLn().toLong() // single long
fun readDouble() = readLn().toDouble() // single double
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints
fun readLongs() = readStrings().map { it.toLong() } // list of longs
fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun calculate(count: Int, k1: Int, k2: Int): Int = if (k2 >= k1 + k1) count * k1
else (count / 2) * k2 + (count % 2) * k1

fun main() {
    val times = readInt()
    repeat(times) {
        var sum = 0
        val (n, k1, k2) = readInts()
        var count = 0
        val days = readLn()

        for (c in days) {
            if (c == '0') {
                sum += calculate(count, k1, k2)
                count = 0
            } else {
                ++count
            }
        }
        sum += calculate(count, k1, k2)
        println(sum)
    }
}


import kotlin.math.roundToInt

fun main() {
    val numberOfCases = readLine()!!.toInt()
    for (case in 1..numberOfCases) {
        val (n, k1, k2) = readLine()!!.split(' ').map { it.toInt() }
        val maxLectures = readLine()!!.split("0")
            .filterNot { it == "" }
            .map { it.length.toDouble() }
            .map {
                when  {
                    it == 1.0 -> k1
                    k1 < k2 / 2 -> (k1 * it).toInt()
                    it % 2 != 0.0 -> (it * k2 / 2).roundToInt() + 1
                    else -> (it * k2 / 2).roundToInt()
                }
            }.sum()

        println(maxLectures)

    }
}


fun main() {
    val numberOfCases = readLine()!!.toInt()
    for (case in 1..numberOfCases) {
        val (n, k1, k2) = readLine()!!.split(' ').map { it.toInt() }
        val dif = k2 - k1
        val maxLectures = readLine()!!.split("0")
            .filterNot { it == "" }
            .map { it.length }
            .map {
                when {
                    it == 1 -> k1
                    dif > k1 -> k1 * it
                    it % 2 == 0 -> k1 * it / 2 + dif * it / 2
                    else -> k1 * (it + 1) / 2 + dif * (it - 1) / 2
                }
            }.sum()

        println(maxLectures)

    }
}


fun main() {
    val numberOfCases = readLine()!!.toInt()
    for (case in 1..numberOfCases) {
        val (n, k1, k2) = readLine()!!.split(' ').map { it.toInt() }
        val dif = k2 - k1
        val maxLectures = readLine()!!.split("0")
            .filterNot { it == "" }
            .map { it.length }
            .map {
                when {
                    it == 1 -> k1
                    it % 2 == 0 -> k1 * it / 2 + dif * it / 2
                    else -> k1 * (it + 1) / 2 + dif * (it - 1) / 2
                }
            }.sum()

        println(maxLectures)

    }
}


fun main() {
    val numberOfCases = readLine()!!.toInt()
    for (case in 1..numberOfCases) {
        val (n, k1, k2) = readLine()!!.split(' ').map { it.toInt() }
        val dif = k2 - k1
        val maxLectures = readLine()!!.split("0")
            .filterNot { it == "" }
            .map { it.length }
            .map {
                when {
                    it == 1 -> k1
                    k1 < k2 / 2 -> k1
                    it % 2 == 0 -> k1 * it / 2 + dif * it / 2
                    else -> k1 * (it + 1) / 2 + dif * (it - 1) / 2
                }
            }.sum()

        println(maxLectures)

    }
}


fun main() {
    val numberOfCases = readLine()!!.toInt()
    for (case in 1..numberOfCases) {
        val (n, k1, k2) = readLine()!!.split(' ').map { it.toInt() }
        val dif = k2 - k1
        val maxLectures = readLine()!!.split("0")
            .filterNot { it == "" }
            .map { it.length }
            .map {
                when {
                    it == 1 -> k1
                    k1 < k2 / 2 -> k1 * it
                    dif > k1 -> k1
                    it % 2 == 0 -> k1 * it / 2 + dif * it / 2
                    else -> k1 * (it + 1) / 2 + dif * (it - 1) / 2
                }
            }.sum()

        println(maxLectures)

    }
}


import java.lang.AssertionError

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main(args: Array<String>) {
    var tt = readInt()
    for (qq in 0 until tt) {
        var (n, k1, k2) = readInts()
        var s = readLn()
        var ans = 0
        var flag = 0
        for (i in 1 until n) {
            if(flag > 0) {
                flag --
                continue
            }
            if(s[i] == '1' && s[i - 1] == '1') {
                ans = ans + k2
                flag ++
            }
            else if(s[i - 1] == '1') {
                ans = ans + k1
            }
            else if(i == n - 1 && s[i] == '1') {
                ans = ans + k1
            }
        }
        println(ans)
    }
}


import java.lang.AssertionError

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main(args: Array<String>) {
    var tt = readInt()
    for (qq in 0 until tt) {
        var (n, k1, k2) = readInts()
        var s = readLn()
        var ans = 0
        var flag = 0
        for (i in 1 until n) {
            if(flag > 0) {
                flag --
                continue
            }
            if(s[i] == '1' && s[i - 1] == '1') {
                if(k2 < k1 * 2) ans = ans + k2
                else ans = ans + k1 * 2
                flag ++
            }
            else if(s[i - 1] == '1') {
                ans = ans + k1
            }
            else if(i == n - 1 && s[i] == '1') {
                ans = ans + k1
            }
        }
        println(ans)
    }
}


import java.lang.AssertionError

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main(args: Array<String>) {
    var tt = readInt()
    for (qq in 0 until tt) {
        var (n, k1, k2) = readInts()
        var s = readLn()
        var ans = 0
        var flag = 0
        for (i in 1 until n) {
            if(flag > 0) {
                if(i == n - 1 && s[i] == '1') {
                    ans = ans + k1
                }
                flag --
                continue
            }
            if(s[i] == '1' && s[i - 1] == '1') {
                if(k2 <= k1 * 2) ans = ans + k2
                else ans = ans + k1 * 2
                flag ++
            }
            else if(s[i - 1] == '1') {
                ans = ans + k1
            }
            else if(i == n - 1 && s[i] == '1') {
                ans = ans + k1
            }
        }
        if(n == 1 && s[0] == '1') println(k1)
        else println(ans)
    }
}


import java.lang.AssertionError

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main(args: Array<String>) {
    var tt = readInt()
    for (qq in 0 until tt) {
        var (n, k1, k2) = readInts()
        var s = readLn()
        var ans = 0
        var flag = 0
        for (i in 1 until n) {
            if(flag > 0) {
                if(i == n - 1 && s[i] == '1') {
                    ans = ans + k1
                }
                flag --
                continue
            }
            if(s[i] == '1' && s[i - 1] == '1') {
                ans = ans + k2
                flag ++
            }
            else if(s[i - 1] == '1') {
                ans = ans + k1
            }
            else if(i == n - 1 && s[i] == '1') {
                ans = ans + k1
            }
        }
        println(ans)
    }
}


import java.lang.AssertionError

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main(args: Array<String>) {
    var tt = readInt()
    for (qq in 0 until tt) {
        var (n, k1, k2) = readInts()
        var s = readLn()
        var ans = 0
        var flag = 0
        for (i in 1 until n) {
            if(flag > 0) {
                if(i == n - 1 && s[i] == '1') {
                    ans = ans + k1
                }
                flag --
                continue
            }
            if(s[i] == '1' && s[i - 1] == '1') {
                ans = ans + k2
                flag ++
            }
            else if(s[i - 1] == '1') {
                ans = ans + k1
            }
            else if(i == n - 1 && s[i] == '1') {
                ans = ans + k1
            }
        }
        if(n == 1 && s[0] == '1') println(k1)
        else println(ans)
    }
}


fun main(args: Array<String>) {
    val tc = readLine()!!.toInt()

    for (input in 1..tc) {
        val (n, k1, k2) = readLine()!!.split(" ").map { it.toInt() }
        val lectureDay = readLine()!!.map { it.toInt() - '0'.toInt() }.toList()

        var count = 0
        var rst = 0
        val twodayMax = if (k1 * 2 > k2) k2 else k1 * 2
        for (i in lectureDay.indices) {
            if(lectureDay[i] == 1) {
                count += 1
            }

            if (lectureDay[i] == 0 || i + 1 >= lectureDay.size) {
                if (count % 2 == 0) {
                    rst += (count / 2) * twodayMax
                }
                else {
                    if (count >= 3) {
                        val evenPart = ((count - 3) / 2) * twodayMax
                        val oddPart = k1 + twodayMax
                        rst += (evenPart + oddPart)
                    } else {
                        rst += k1
                    }
                }
                count = 0
            }
        }

        println("$rst")
    }
}


fun main(args: Array<String>) {
    val tc = readLine()!!.toInt()

    for (input in 1..tc) {
        val (n, k1, k2) = readLine()!!.split(" ").map { it.toInt() }
        val lectureDay = readLine()!!.map { it.toInt() - '0'.toInt() }.toList()

        var count = 0
        var rst = 0
        for (i in lectureDay.indices) {
            if(lectureDay[i] == 1) {
                count += 1
            }

            if (lectureDay[i] == 0 || i + 1 >= lectureDay.size) {
                if (count % 2 == 0) {
                    rst += (count / 2) * k2
                }
                else {
                    if (count >= 3) {
                        val evenPart = ((count - 3) / 2) * k2
                        val oddPart = k1 + k1 + (k2 - k1)
                        rst += (evenPart + oddPart)
                    } else {
                        rst += k1
                    }
                }
                count = 0
            }
        }

        println("$rst")
    }
}


fun main(args: Array<String>) {
    val tc = readLine()!!.toInt()

    for (input in 1..tc) {
        val (n, k1, k2) = readLine()!!.split(" ").map { it.toInt() }
        val lectureDay = readLine()!!.map { it.toInt() - '0'.toInt() }.toList()

        var count = 0
        var rst = 0
        for (i in lectureDay.indices) {
            if(lectureDay[i] == 1) {
                count += 1
            }

            if (lectureDay[i] == 0 || i + 1 >= lectureDay.size) {
                if (count > 3 && count % 2 == 1) {
                    println("###")
                    val evenPart = ((count - 3) / 2) * k2
                    val oddPart = k1 + k1 + (k2 - k1)
                    rst += (evenPart + oddPart)
                } else if (count % 2 == 0) {
                    rst += (count / 2) * k2
                } else {
                    rst += k1
                }
                count = 0
            }
        }

        println("$rst")
    }
}


fun main(args: Array<String>) {
    val tc = readLine()!!.toInt()

    for (input in 1..tc) {
        val (n, k1, k2) = readLine()!!.split(" ").map { it.toInt() }
        val lectureDay = readLine()!!.map { it.toInt() - '0'.toInt() }.toList()

        var count = 0
        var rst = 0
        for (i in lectureDay.indices) {
            if(lectureDay[i] == 1) {
                count += 1
            }

            if (lectureDay[i] == 0 || i + 1 >= lectureDay.size) {
                //println("i: $i, count: $count")
                if (count > 3 || count % 2 == 1) {
                    val evenPart = ((count - 3) / 2) * k2
                    val oddPart = k1 + k1 + (k2 - k1)
                    rst += (evenPart + oddPart)
                } else if (count % 2 == 0) {
                    rst += (count / 2) * k2
                } else {
                    rst += k1
                }
                count = 0
            }
        }

        println("$rst")
    }
}


fun main(args: Array<String>) {
    val tc = readLine()!!.toInt()

    for (input in 1..tc) {
        val (n, k1, k2) = readLine()!!.split(" ").map { it.toInt() }
        val lectureDay = readLine()!!.map { it.toInt() - '0'.toInt() }.toList()

        var count = 0
        var rst = 0
        for (i in lectureDay.indices) {
            if(lectureDay[i] == 1) {
                count += 1
            }

            if (lectureDay[i] == 0 || i + 1 >= lectureDay.size) {
                if (count >= 3 && count % 2 == 1) {
                    val evenPart = ((count - 3) / 2) * k2
                    val oddPart = k1 + k1 + (k2 - k1)
                    rst += (evenPart + oddPart)
                } else if (count % 2 == 0) {
                    rst += (count / 2) * k2
                } else {
                    rst += k1
                }
                count = 0
            }
        }

        println("$rst")
    }
}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    val t = readInt()
    for (i in 1..t) {
        val (n, k1, k2) = readInts()
        val s = readLn()
        println(calculate(n, k1, k2, s))
    }
}

//k1 the number of lectures for each day should not exceed
//k2 the number of lectures for each pair of consecutive days should not exceed
fun calculate(n: Int, k1: Int, k2: Int, s: String): Int {
    val lectures = MutableList(n / 2) { 0 }
    var group = 0
    var groupSize = 0
    s.forEach {
        groupSize++
        if (groupSize > 2) {
            groupSize = 0
            group++
        }

        if (it == '1') {
            lectures[group] += k1

            if (lectures[group] > k2) {
                lectures[group] = k2
            }
        }

    }
    return lectures.sum()
}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    val t = readInt()
    for (i in 1..t) {
        val (n, k1, k2) = readInts()
        val s = readLn()
        println(calculate(n, k1, k2, s))
    }
}

//k1 the number of lectures for each day should not exceed
//k2 the number of lectures for each pair of consecutive days should not exceed
fun calculate(n: Int, k1: Int, k2: Int, s: String): Int {
    var m = 0;
    s.split("0").forEach {
        var maxLectures = 0
        for (i in 1..it.length) {
            maxLectures += k1;
            if (maxLectures > k2 || i % 2 == 0) {
                m += k2
                maxLectures = 0
            }
        }
        m += maxLectures
    }
    return m
}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    val t = readInt()
    for (i in 1..t) {
        val (n, k1, k2) = readInts()
        val s = readLn()
        println(calculate(n, k1, k2, s))
    }
}

//k1 the number of lectures for each day should not exceed
//k2 the number of lectures for each pair of consecutive days should not exceed
fun calculate(n: Int, k1: Int, k2: Int, s: String): Int {
    var m = 0;
    s.split("0").forEach {
        var maxLectures = 0
        for (i in 1..it.length) {
            maxLectures += k1;
            if (maxLectures > k2) {
                m += k2
                maxLectures = 0
            }
        }
        m += maxLectures
    }
    return m
}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLongs() = readStrings().map { it.toInt() } // list of ints

fun main() {
    val t = readInt()
    for (i in 1..t) {
        val (n, k1, k2) = readLongs()
        val s = readLn()
        println(calculate(n, k1, k2, s))
    }
}

//k1 the number of lectures for each day should not exceed
//k2 the number of lectures for each pair of consecutive days should not exceed
fun calculate(n: Int, k1: Int, k2: Int, s: String): Int {
    val lectures = MutableList(n / 2) { 0 }
    var group = 0
    var groupSize = 0
    s.forEach {
        groupSize++
        if (groupSize > 2) {
            groupSize = 0
            group++
        }

        if (it == '1') {
            lectures[group] += k1

            if (lectures[group] > k2) {
                lectures[group] = k2
            }
        }

    }
    return lectures.sum()
}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLongs() = readStrings().map { it.toInt() } // list of ints

fun main() {
    val t = readInt()
    for (i in 1..t) {
        val (_, k1, k2) = readLongs()
        val s = readLn()
        println(calculate(k1, k2, s))
    }

//    println(calculate(5, 7, "1011")) //12
//    println(calculate(6889, 9202, "000100011101000101100101011000001010010111011000100")) //121789
}

//k1 the number of lectures for each day should not exceed
//k2 the number of lectures for each pair of consecutive days should not exceed
fun calculate(k1: Int, k2: Int, s: String): Int {
    var m = 0
    s.split("0").map { group ->
        val n = mutableListOf<Int>()
        repeat(group.length) {
            n += k1
            if ((it + 1) % 2 == 0) {
                if (n.takeLast(2).sum() > k2) {
                    n[it] -= n.takeLast(2).sum() - k2
                }
            }
        }
        m += n.sum()
    }
    return m
}


fun main() {
    lectures()
}

fun lectures () {
    val testCases = readLine()?.toInt() ?: 0
    for (i in 0 until testCases) {
        val variables = readLine()?.split(' ')
        val n: Int = variables!![0].toInt()
        val k1: Int = variables[1].toInt()
        val k2: Int = variables[2].toInt()
        val e = readLine()?.toCharArray()?.toCollection(ArrayList()) ?: ArrayList<Char>()
        var isPrevNotMax = true
        var m = 0
        for (l: Int in 0 until n) {
            if (e[l] == '1') {
                if (isPrevNotMax) {
                    m += k1
                    isPrevNotMax = false
                } else {
                    m = m + k2 - k1
                    isPrevNotMax = true
                }
            } else {
                isPrevNotMax = true
            }
        }
        println(m)
    }
}


fun main() {
    //numbers()
    lectures()
}

fun lectures () {
    val testCases = readLine()?.toInt() ?: 0
    for (i in 0 until testCases) {
        val variables = readLine()?.split(' ')
        val n: Int = variables!![0].toInt()
        val k1: Int = variables[1].toInt()
        val k2: Int = variables[2].toInt()
        val e = readLine()?.toCharArray()?.toCollection(ArrayList()) ?: ArrayList<Char>()
        var isPrevNotMax = true
        var m = 0
        for (l: Int in 0 until n) {
            if (e[l] == '1') {
                if (isPrevNotMax) {
                    m += k1
                    isPrevNotMax = false
                } else {
                    m = m + k2 - k1
                    isPrevNotMax = true
                }
            } else {
                isPrevNotMax = true
            }
        }
        println(m)
    }
}


fun main() {
    //numbers()
    lectures()
}

fun lectures () {
    val testCases = readLine()?.toInt() ?: 0
    for (i in 0 until testCases) {
        val variables = readLine()?.split(' ')
        val n: Int = variables!![0].toInt()
        val k1: Int = variables[1].toInt()
        val k2: Int = variables[2].toInt()
        val e = readLine()?.split(' ') ?: emptyList()
        var isPrevNotMax = true
        var m = 0
        for (l: Int in 0 until n) {
            if (e[l].toInt() == 1) {
                if (isPrevNotMax) {
                    m += k1
                    isPrevNotMax = false
                } else {
                    m = m + k2 - k1
                    isPrevNotMax = true
                }
            } else {
                isPrevNotMax = true
            }
        }
        println(m)
    }
}


fun main() {
    //numbers()
    lectures()
}

fun lectures () {
    val testCases = readLine()?.toInt() ?: 0
    for (i in 0 until testCases) {
        val variables = readLine()?.split(' ')
        val n: Int = variables!![0].toInt()
        val k1: Int = variables[1].toInt()
        val k2: Int = variables[2].toInt()
        val e = readLine()?.toCharArray()?.toCollection(ArrayList()) ?: ArrayList<Char>()
        var isPrevNotMax = true
        var m = 0
        for (l: Int in 0 until n) {
            if (e[l] == '1') {
                if (isPrevNotMax) {
                    m += k1
                    isPrevNotMax = false
                } else {
                    if (k2 - k1 > k1) {
                        m = m + k1
                        isPrevNotMax = false
                    } else {
                        m = m + k2 - k1
                        isPrevNotMax = true
                    }

                }
            } else {
                isPrevNotMax = true
            }
        }
        println(m)
    }
}


fun main() {
    //numbers()
    lectures()
}

fun lectures () {
    val testCases = readLine()?.toInt() ?: 0
    for (i in 0 until testCases) {
        val variables = readLine()?.split(' ')
        val n: Int = variables!![0].toInt()
        val k1: Int = variables[1].toInt()
        val k2: Int = variables[2].toInt()
        val e = readLine()?.toCharArray()?.toCollection(ArrayList()) ?: ArrayList<Char>()
        var isPrevNotMax = true
        var m = 0
        for (l: Int in 0 until n) {
            if (e[l].toInt() == 1) {
                if (isPrevNotMax) {
                    m += k1
                    isPrevNotMax = false
                } else {
                    m = m + k2 - k1
                    isPrevNotMax = true
                }
            } else {
                isPrevNotMax = true
            }
        }
        println(m)
    }
}


import java.io.*;
import java.io.BufferedReader
import java.math.BigInteger
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.max
import kotlin.math.min

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles
//Fast IO: https://github.com/finalchild/kotlin-fast-io/blob/master/src/solution.kt#L97

fun main(){
    var t = readInt()
    while(t-- > 0){
        var (n, k1 , k2) = readInts()
        var s = readStrings()
        var l = 0
        var r = n-1
        var ans = 0
        var prev = 0

        while(l <= r){
            if(s[0][l].equals('1')){
               if(l - 1 >= 0 && s[0][l-1].equals('1')){
                  ans += k2 - prev;
                  prev = k2 - prev;
               }
               else{
                  ans += k1
                  prev = k1
               }
            }
            else{
               prev = 0
            }
            l ++
        }
        println("$ans")

    }
}


import java.io.*;
import java.io.BufferedReader
import java.math.BigInteger
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.max
import kotlin.math.min

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles
//Fast IO: https://github.com/finalchild/kotlin-fast-io/blob/master/src/solution.kt#L97

fun main(){
    var t = readInt()
    while(t-- > 0){
        var (n, k1 , k2) = readLongs()
        var s = readStrings()
        var l = 0
        var r = n-1
        var ans : Long= 0
        var prev : Long= 0

        while(l <= r){
            if(s[0][l].equals('1')){
               if(l - 1 >= 0 && s[0][l-1].equals('1')){
                  ans += max(0 ,k2 - prev);
                  prev = max(0 ,k2 - prev);
               }
               else{
                  ans += k1
                  prev = k1
               }
            }
            else{
               prev = 0
            }
            l ++
        }
        println("$ans")

    }
}


import java.io.*;
import java.io.BufferedReader
import java.math.BigInteger
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.max
import kotlin.math.min

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles
//Fast IO: https://github.com/finalchild/kotlin-fast-io/blob/master/src/solution.kt#L97

fun main(){
    var t = readInt()
    while(t-- > 0){
        var (n, k1 , k2) = readLongs()
        var s = readStrings()
        var l = 0
        var r = n-1
        var ans : Long= 0
        var prev : Long= 0

        while(l <= r){
            if(s[0][l].equals('1')){
               if(l - 1 >= 0 && s[0][l-1].equals('1')){
                  ans += k2 - prev;
                  prev = k2 - prev;
               }
               else{
                  ans += k1
                  prev = k1
               }
            }
            else{
               prev = 0
            }
            l ++
        }
        println("$ans")

    }
}


import java.io.*;
import java.io.BufferedReader
import java.math.BigInteger
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.max
import kotlin.math.min

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles
//Fast IO: https://github.com/finalchild/kotlin-fast-io/blob/master/src/solution.kt#L97

fun main(){
    var t = readInt()
    while(t-- > 0){
        var (n, k1 , k2) = readLongs()
        var s = readStrings()
        var l = 0
        var r = n-1
        var ans : Long= 0
        var prev : Long= 0

        while(l <= r){
            if(s[0][l].equals('1')){
               if(l - 1 >= 0 && s[0][l-1].equals('1')){
                  ans += min(max(0 ,k2 - prev) , k1)
                  prev = min(max(0 ,k2 - prev) , k1)
               }
               else{
                  ans += k1
                  prev = k1
               }
            }
            else{
               prev = 0
            }
            l ++
        }
        println("$ans")

    }
}


fun main() {
    val nbTestsCases = readLine()!!.toInt()
    for (i in 0..nbTestsCases) {
        val line = readLine()
        val availableDays = readLine()
        if (line != null) {
            val n = line.split(" ")[0].toInt()
            val k1 = line.split(" ")[1].toInt()
            val k2 = line.split(" ")[2].toInt()
            val days = availableDays!!.map { it == '1' }
            val lectureByDay = days.mapIndexed { index, available ->
                if (!available) {
                    0
                } else {
                    k1
                }
            }
            val lecturesByDay = lectureByDay.mapIndexed { index, sum ->
                if (index - 1 >= 0) {
                    if (lectureByDay[index - 1] + lectureByDay[index] > k2) {
                        lectureByDay[index] + (k2 - (lectureByDay[index - 1] + lectureByDay[index]))
                    } else {
                        lectureByDay[index]
                    }
                } else {
                    lectureByDay[index]
                }
            }
            val max = lecturesByDay.sum()
            println(max)
        }
    }
}


fun main() {
    val nbTestsCases = readLine()!!.toInt()
    for (i in 0..nbTestsCases) {
        val line = readLine()
        val availableDays = readLine()
        if (line != null) {
            val k1 = line.split(" ")[1].toInt()
            val k2 = line.split(" ")[2].toInt()
            val days = availableDays!!.map { it == '1' }
            val lectureByDay = days.mapIndexed { index, available ->
                if (!available) {
                    0
                } else {
                    k1
                }
            }.toMutableList()
            var previousDay: Int? = null
            for(index in 0 until days.size) {
                if(!days[index]) {
                    lectureByDay[index] = 0
                    previousDay = 0
                } else if(previousDay == null) {
                    lectureByDay[index] = k1
                    previousDay = k1
                } else {
                    lectureByDay[index] = max(k1, k2 - previousDay)
                    previousDay = max(k1, k2 - previousDay)
                }
            }
            val max = lectureByDay.sum()
            println(max)
        }
    }
}


import kotlin.math.max

fun main() {
    val nbTestsCases = readLine()!!.toInt()
    for (i in 0..nbTestsCases) {
        val line = readLine()
        val availableDays = readLine()
        if (line != null) {
            val k1 = line.split(" ")[1].toInt()
            val k2 = line.split(" ")[2].toInt()
            val days = availableDays!!.map { it == '1' }
            val lectureByDay = days.mapIndexed { index, available ->
                if (!available) {
                    0
                } else {
                    k1
                }
            }.toMutableList()
            var previousDay: Int? = null
            for(index in 0 until days.size) {
                if(!days[index]) {
                    lectureByDay[index] = 0
                    previousDay = 0
                } else if(previousDay == null) {
                    lectureByDay[index] = k1
                    previousDay = k1
                } else {
                    lectureByDay[index] = max(k1, k2 - previousDay)
                    previousDay = max(k1, k2 - previousDay)
                }
            }
            val max = lectureByDay.sum()
            println(max)
        }
    }
}


fun main() {
    val nbTestsCases = readLine()!!.toInt()
    for (i in 0..nbTestsCases) {
        val line = readLine()
        val availableDays = readLine()
        if (line != null) {
            val n = line.split(" ")[0].toInt()
            val k1 = line.split(" ")[1].toInt()
            val k2 = line.split(" ")[2].toInt()
            val days = availableDays!!.map { it == '1' }
            val lectureByDay = days.mapIndexed { index, available ->
                if (!available) {
                    0
                } else {
                    k1
                }
            }
            val lecturesByDay = lectureByDay.mapIndexed { index, sum ->
                if (index - 1 > 0) {
                    if (lectureByDay[index - 1] + lectureByDay[index] > k2) {
                        lectureByDay[index] + (k2 - (lectureByDay[index - 1] + lectureByDay[index]))
                    } else {
                        lectureByDay[index]
                    }
                } else {
                    lectureByDay[index]
                }
            }
            val max = lecturesByDay.sum()
            println(max)
        }
    }
}


import kotlin.math.max

fun main() {
    val nbTestsCases = readLine()!!.toInt()
    for (i in 0..nbTestsCases) {
        val line = readLine()
        val availableDays = readLine()
        if (line != null) {
            val k1 = line.split(" ")[1].toInt()
            val k2 = line.split(" ")[2].toInt()
            val days = availableDays!!.map { it == '1' }
            val lectureByDay = days.mapIndexed { index, available ->
                if (!available) {
                    0
                } else {
                    k1
                }
            }.toMutableList()
            var previousDay: Int? = null
            for(index in 0 until days.size) {
                if(!days[index]) {
                    lectureByDay[index] = 0
                    previousDay = 0
                } else if(previousDay == null) {
                    lectureByDay[index] = k1
                    previousDay = k1
                } else {
                    lectureByDay[index] = max(k1, k2 - previousDay)
                    previousDay = max(k1, k2 - previousDay)
                }
            }
            val max = lectureByDay.sum()
            println(lectureByDay)
        }
    }
}


import kotlin.math.max
import kotlin.math.min

fun main() {
    val nbTestsCases = readLine()!!.toInt()
    for (i in 0..nbTestsCases) {
        val line = readLine()
        val availableDays = readLine()
        if (line != null) {
            val k1 = line.split(" ")[1].toInt()
            val k2 = line.split(" ")[2].toInt()
            val days = availableDays!!.map { it == '1' }
            val lectureByDay = days.mapIndexed { index, available ->
                if (!available) {
                    0
                } else {
                    k1
                }
            }.toMutableList()
            var previousDay: Int? = null
            for(index in 0 until days.size) {
                if(!days[index]) {
                    lectureByDay[index] = 0
                    previousDay = 0
                } else if(previousDay == null) {
                    lectureByDay[index] = k1
                    previousDay = k1
                } else {
                    lectureByDay[index] = min(k1, k2 - previousDay)
                    previousDay = min(k1, k2 - previousDay)
                }
            }
            val max = lectureByDay.sum()
            println(max)
        }
    }
}


import java.math.BigInteger
import java.util.*

fun main() {
    val sc = Scanner(System.`in`)
    val t = sc.nextInt()

    for(i in 0 until t) {
        val n = sc.nextInt()
        val singleCost = sc.nextLong()
        val doubleCost = sc.nextLong()

        sc.nextLine()

        val tempStr = sc.nextLine()
        val str= tempStr.toCharArray()

        var ans : Long = 0

        for(i in str.indices) {
            if(str[i] == '1') {
                if(i + 1 < str.size && str[i + 1] == '1') {
                    ans += doubleCost.coerceAtMost(2 * singleCost)
                    str[i] = '0'
                    str[i + 1] = '0'
                } else {
                    str[i] = '0'
                    ans += singleCost
                }
            }
        }

        println(ans)
    }
}


import java.math.BigInteger
import java.util.*

fun main() {
    val sc = Scanner(System.`in`)
    val t = sc.nextInt()

    for(_t in 0 until t) {
        val n = sc.nextInt()
        val singleCost = sc.nextLong()
        val doubleCost = sc.nextLong()

        sc.nextLine()

        val tempStr = sc.nextLine()
        val str= tempStr.toCharArray()

        var ans : Long = 0

        for(i in str.indices) {
            if(str[i] == '1') {
                if(i + 1 < str.size && str[i + 1] == '1') {
                    ans += doubleCost.coerceAtMost(2 * singleCost)
                    str[i] = '0'
                    str[i + 1] = '0'
                } else {
                    str[i] = '0'
                    ans += singleCost
                }
            }
        }

        println(ans)
    }
}


import java.math.BigInteger
import java.util.*

fun main() {
    val sc = Scanner(System.`in`)
    val t = sc.nextInt()

    for(i in 0 until t) {
        val n = sc.nextInt()
        val singleCost = sc.nextLong()
        val doubleCost = sc.nextLong()

        sc.nextLine()

        val tempStr = sc.nextLine()
        val str= tempStr.toCharArray()

        var ans : Long = 0

        for(i in str.indices) {
            if(str[i] == '1') {
                if(i + 1 < str.size && str[i + 1] == '1') {
                    ans += doubleCost
                    str[i] = '0'
                    str[i + 1] = '0'
                } else {
                    str[i] = '0'
                    ans += singleCost
                }
            }
        }

        println(ans)
    }
}


private fun readln() = readLine()!!
private fun readlnByte() = readln().toByte()
private fun readlnShort() = readln().toShort()
private fun readlnInt() = readln().toInt()
private fun readlnLong() = readln().toLong()
private fun readlnFloat() = readln().toFloat()
private fun readlnDouble() = readln().toDouble()
private fun readlnBigInt(radix: Int = 10) = readln().toBigInteger(radix)
private fun readlnBigDecimal() = readln().toBigDecimal()

private fun lineSequence(limit: Int = Int.MAX_VALUE) = generateSequence { readLine() }.constrainOnce().take(limit)
private fun readlnStrings() = readln().split(' ')
private fun readlnBytes() = readlnStrings().map { it.toByte() }
private fun readlnShorts() = readlnStrings().map { it.toShort() }
private fun readlnInts() = readlnStrings().map { it.toInt() }
private fun readlnLongs() = readlnStrings().map { it.toLong() }
private fun readlnFloats() = readlnStrings().map { it.toFloat() }
private fun readlnDoubles() = readlnStrings().map { it.toDouble() }

private fun readByteArray() = readlnStrings().run { ByteArray(size) { get(it).toByte() } }
private fun readShortArray() = readlnStrings().run { ShortArray(size) { get(it).toShort() } }
private fun readIntArray() = readlnStrings().run { IntArray(size) { get(it).toInt() } }
private fun readLongArray() = readlnStrings().run { LongArray(size) { get(it).toLong() } }
private fun readFloatArray() = readlnStrings().run { FloatArray(size) { get(it).toFloat() } }
private fun readDoubleArray() = readlnStrings().run { DoubleArray(size) { get(it).toDouble() } }

private fun readlnByteArray(n: Int) = ByteArray(n) { readlnByte() }
private fun readlnShortArray(n: Int) = ShortArray(n) { readlnShort() }
private fun readlnIntArray(n: Int) = IntArray(n) { readlnInt() }
private fun readlnLongArray(n: Int) = LongArray(n) { readlnLong() }
private fun readlnFloatArray(n: Int) = FloatArray(n) { readlnFloat() }
private fun readlnDoubleArray(n: Int) = DoubleArray(n) { readlnDouble() }

private fun readByteArray2d(rows: Int, cols: Int) = Array(rows) { readByteArray().also { require(it.size == cols) } }
private fun readShortArray2d(rows: Int, cols: Int) = Array(rows) { readShortArray().also { require(it.size == cols) } }
private fun readLongArray2d(rows: Int, cols: Int) = Array(rows) { readLongArray().also { require(it.size == cols) } }
private fun readIntArray2d(rows: Int, cols: Int) = Array(rows) { readIntArray().also { require(it.size == cols) } }
private fun readFloatArray2d(rows: Int, cols: Int) = Array(rows) { readFloatArray().also { require(it.size == cols) } }
private fun readDoubleArray2d(rows: Int, cols: Int) =
    Array(rows) { readDoubleArray().also { require(it.size == cols) } }

private fun isWhiteSpace(c: Char) = c in " \r\n\t"

// JVM-only targeting code follows next

// readString() via sequence is still slightly faster than Scanner
private fun readString() = generateSequence { System.`in`.read().toChar() }
    .dropWhile { isWhiteSpace(it) }.takeWhile { !isWhiteSpace(it) }.joinToString("")

private fun readByte() = readString().toByte()
private fun readShort() = readString().toShort()
private fun readInt() = readString().toInt()
private fun readLong() = readString().toLong()
private fun readFloat() = readString().toFloat()
private fun readDouble() = readString().toDouble()
private fun readBigInt(radix: Int = 10) = readString().toBigInteger(radix)
private fun readBigDecimal() = readString().toBigDecimal()

private fun readBytes(n: Int) = generateSequence { readByte() }.take(n)
private fun readShorts(n: Int) = generateSequence { readShort() }.take(n)
private fun readInts(n: Int) = generateSequence { readInt() }.take(n)
private fun readLongs(n: Int) = generateSequence { readLong() }.take(n)
private fun readFloats(n: Int) = generateSequence { readFloat() }.take(n)
private fun readDoubles(n: Int) = generateSequence { readDouble() }.take(n)

fun main() {
    repeat(readInt()) {
        readInt()
        val k1 = readInt()
        val k2 = readInt()
        val days = readln()
        var c = 0
        var count = 0
        while (c < days.count() - 1) {
            if (days[c] == '1') {
                count += if (days[c + 1] == '1') {
                    k2
                } else {
                    k1
                }
                c += 2
            } else {
                c++
            }
        }
        if (c == (days.count() - 1) && days[c] == '1') {
            count += k1
        }
        println(count)
    }
}


package contest

import kotlin.math.pow

private fun readln() = readLine()!!
private fun readlnByte() = readln().toByte()
private fun readlnShort() = readln().toShort()
private fun readlnInt() = readln().toInt()
private fun readlnLong() = readln().toLong()
private fun readlnFloat() = readln().toFloat()
private fun readlnDouble() = readln().toDouble()
private fun readlnBigInt(radix: Int = 10) = readln().toBigInteger(radix)
private fun readlnBigDecimal() = readln().toBigDecimal()

private fun lineSequence(limit: Int = Int.MAX_VALUE) = generateSequence { readLine() }.constrainOnce().take(limit)
private fun readlnStrings() = readln().split(' ')
private fun readlnBytes() = readlnStrings().map { it.toByte() }
private fun readlnShorts() = readlnStrings().map { it.toShort() }
private fun readlnInts() = readlnStrings().map { it.toInt() }
private fun readlnLongs() = readlnStrings().map { it.toLong() }
private fun readlnFloats() = readlnStrings().map { it.toFloat() }
private fun readlnDoubles() = readlnStrings().map { it.toDouble() }

private fun readByteArray() = readlnStrings().run { ByteArray(size) { get(it).toByte() } }
private fun readShortArray() = readlnStrings().run { ShortArray(size) { get(it).toShort() } }
private fun readIntArray() = readlnStrings().run { IntArray(size) { get(it).toInt() } }
private fun readLongArray() = readlnStrings().run { LongArray(size) { get(it).toLong() } }
private fun readFloatArray() = readlnStrings().run { FloatArray(size) { get(it).toFloat() } }
private fun readDoubleArray() = readlnStrings().run { DoubleArray(size) { get(it).toDouble() } }

private fun readlnByteArray(n: Int) = ByteArray(n) { readlnByte() }
private fun readlnShortArray(n: Int) = ShortArray(n) { readlnShort() }
private fun readlnIntArray(n: Int) = IntArray(n) { readlnInt() }
private fun readlnLongArray(n: Int) = LongArray(n) { readlnLong() }
private fun readlnFloatArray(n: Int) = FloatArray(n) { readlnFloat() }
private fun readlnDoubleArray(n: Int) = DoubleArray(n) { readlnDouble() }

private fun readByteArray2d(rows: Int, cols: Int) = Array(rows) { readByteArray().also { require(it.size == cols) } }
private fun readShortArray2d(rows: Int, cols: Int) = Array(rows) { readShortArray().also { require(it.size == cols) } }
private fun readLongArray2d(rows: Int, cols: Int) = Array(rows) { readLongArray().also { require(it.size == cols) } }
private fun readIntArray2d(rows: Int, cols: Int) = Array(rows) { readIntArray().also { require(it.size == cols) } }
private fun readFloatArray2d(rows: Int, cols: Int) = Array(rows) { readFloatArray().also { require(it.size == cols) } }
private fun readDoubleArray2d(rows: Int, cols: Int) =
    Array(rows) { readDoubleArray().also { require(it.size == cols) } }

private fun isWhiteSpace(c: Char) = c in " \r\n\t"

// JVM-only targeting code follows next

// contest.readString() via sequence is still slightly faster than Scanner
private fun readString() = generateSequence { System.`in`.read().toChar() }
    .dropWhile { isWhiteSpace(it) }.takeWhile { !isWhiteSpace(it) }.joinToString("")

private fun readByte() = readString().toByte()
private fun readShort() = readString().toShort()
private fun readInt() = readString().toInt()
private fun readLong() = readString().toLong()
private fun readFloat() = readString().toFloat()
private fun readDouble() = readString().toDouble()
private fun readBigInt(radix: Int = 10) = readString().toBigInteger(radix)
private fun readBigDecimal() = readString().toBigDecimal()

private fun readBytes(n: Int) = generateSequence { readByte() }.take(n)
private fun readShorts(n: Int) = generateSequence { readShort() }.take(n)
private fun readInts(n: Int) = generateSequence { readInt() }.take(n)
private fun readLongs(n: Int) = generateSequence { readLong() }.take(n)
private fun readFloats(n: Int) = generateSequence { readFloat() }.take(n)
private fun readDoubles(n: Int) = generateSequence { readDouble() }.take(n)

fun main() {
    repeat(readInt()) {
        val n = readInt()
        val k = readInt()
        val kD = k.toDouble()
        val n1 = (n / (1 + k + kD.pow(2) + kD.pow(3))).toInt()
        val n2 = k * n1
        val n3 = k * n2
        val n4 = k * n3
        println("$n1 $n2 $n3 $n4")
    }
}


private fun readln() = readLine()!!
private fun readlnByte() = readln().toByte()
private fun readlnShort() = readln().toShort()
private fun readlnInt() = readln().toInt()
private fun readlnLong() = readln().toLong()
private fun readlnFloat() = readln().toFloat()
private fun readlnDouble() = readln().toDouble()
private fun readlnBigInt(radix: Int = 10) = readln().toBigInteger(radix)
private fun readlnBigDecimal() = readln().toBigDecimal()

private fun lineSequence(limit: Int = Int.MAX_VALUE) = generateSequence { readLine() }.constrainOnce().take(limit)
private fun readlnStrings() = readln().split(' ')
private fun readlnBytes() = readlnStrings().map { it.toByte() }
private fun readlnShorts() = readlnStrings().map { it.toShort() }
private fun readlnInts() = readlnStrings().map { it.toInt() }
private fun readlnLongs() = readlnStrings().map { it.toLong() }
private fun readlnFloats() = readlnStrings().map { it.toFloat() }
private fun readlnDoubles() = readlnStrings().map { it.toDouble() }

private fun readByteArray() = readlnStrings().run { ByteArray(size) { get(it).toByte() } }
private fun readShortArray() = readlnStrings().run { ShortArray(size) { get(it).toShort() } }
private fun readIntArray() = readlnStrings().run { IntArray(size) { get(it).toInt() } }
private fun readLongArray() = readlnStrings().run { LongArray(size) { get(it).toLong() } }
private fun readFloatArray() = readlnStrings().run { FloatArray(size) { get(it).toFloat() } }
private fun readDoubleArray() = readlnStrings().run { DoubleArray(size) { get(it).toDouble() } }

private fun readlnByteArray(n: Int) = ByteArray(n) { readlnByte() }
private fun readlnShortArray(n: Int) = ShortArray(n) { readlnShort() }
private fun readlnIntArray(n: Int) = IntArray(n) { readlnInt() }
private fun readlnLongArray(n: Int) = LongArray(n) { readlnLong() }
private fun readlnFloatArray(n: Int) = FloatArray(n) { readlnFloat() }
private fun readlnDoubleArray(n: Int) = DoubleArray(n) { readlnDouble() }

private fun readByteArray2d(rows: Int, cols: Int) = Array(rows) { readByteArray().also { require(it.size == cols) } }
private fun readShortArray2d(rows: Int, cols: Int) = Array(rows) { readShortArray().also { require(it.size == cols) } }
private fun readLongArray2d(rows: Int, cols: Int) = Array(rows) { readLongArray().also { require(it.size == cols) } }
private fun readIntArray2d(rows: Int, cols: Int) = Array(rows) { readIntArray().also { require(it.size == cols) } }
private fun readFloatArray2d(rows: Int, cols: Int) = Array(rows) { readFloatArray().also { require(it.size == cols) } }
private fun readDoubleArray2d(rows: Int, cols: Int) =
    Array(rows) { readDoubleArray().also { require(it.size == cols) } }

private fun isWhiteSpace(c: Char) = c in " \r\n\t"

// JVM-only targeting code follows next

// readString() via sequence is still slightly faster than Scanner
private fun readString() = generateSequence { System.`in`.read().toChar() }
    .dropWhile { isWhiteSpace(it) }.takeWhile { !isWhiteSpace(it) }.joinToString("")

private fun readByte() = readString().toByte()
private fun readShort() = readString().toShort()
private fun readInt() = readString().toInt()
private fun readLong() = readString().toLong()
private fun readFloat() = readString().toFloat()
private fun readDouble() = readString().toDouble()
private fun readBigInt(radix: Int = 10) = readString().toBigInteger(radix)
private fun readBigDecimal() = readString().toBigDecimal()

private fun readBytes(n: Int) = generateSequence { readByte() }.take(n)
private fun readShorts(n: Int) = generateSequence { readShort() }.take(n)
private fun readInts(n: Int) = generateSequence { readInt() }.take(n)
private fun readLongs(n: Int) = generateSequence { readLong() }.take(n)
private fun readFloats(n: Int) = generateSequence { readFloat() }.take(n)
private fun readDoubles(n: Int) = generateSequence { readDouble() }.take(n)

fun main() {
    repeat(readlnInt()) {
        val (d, k1, k2) = readIntArray()
        val days = readln()
        var c = 0
        var count = 0
        while (c < days.count() - 1) {
            if (days[c] == '1') {
                count += if (days[c + 1] == '1') {
                    if (k2 >= k1 * 2) {
                        k1 * 2
                    } else {
                        k2
                    }
                } else {
                    k1
                }
                c += 2
            } else {
                c++
            }
        }
        if (c == (days.count() - 1) && days[c] == '1') {
            count += k1
        }
        println(count)
    }
}


private fun readln() = readLine()!!
private fun readlnByte() = readln().toByte()
private fun readlnShort() = readln().toShort()
private fun readlnInt() = readln().toInt()
private fun readlnLong() = readln().toLong()
private fun readlnFloat() = readln().toFloat()
private fun readlnDouble() = readln().toDouble()
private fun readlnBigInt(radix: Int = 10) = readln().toBigInteger(radix)
private fun readlnBigDecimal() = readln().toBigDecimal()

private fun lineSequence(limit: Int = Int.MAX_VALUE) = generateSequence { readLine() }.constrainOnce().take(limit)
private fun readlnStrings() = readln().split(' ')
private fun readlnBytes() = readlnStrings().map { it.toByte() }
private fun readlnShorts() = readlnStrings().map { it.toShort() }
private fun readlnInts() = readlnStrings().map { it.toInt() }
private fun readlnLongs() = readlnStrings().map { it.toLong() }
private fun readlnFloats() = readlnStrings().map { it.toFloat() }
private fun readlnDoubles() = readlnStrings().map { it.toDouble() }

private fun readByteArray() = readlnStrings().run { ByteArray(size) { get(it).toByte() } }
private fun readShortArray() = readlnStrings().run { ShortArray(size) { get(it).toShort() } }
private fun readIntArray() = readlnStrings().run { IntArray(size) { get(it).toInt() } }
private fun readLongArray() = readlnStrings().run { LongArray(size) { get(it).toLong() } }
private fun readFloatArray() = readlnStrings().run { FloatArray(size) { get(it).toFloat() } }
private fun readDoubleArray() = readlnStrings().run { DoubleArray(size) { get(it).toDouble() } }

private fun readlnByteArray(n: Int) = ByteArray(n) { readlnByte() }
private fun readlnShortArray(n: Int) = ShortArray(n) { readlnShort() }
private fun readlnIntArray(n: Int) = IntArray(n) { readlnInt() }
private fun readlnLongArray(n: Int) = LongArray(n) { readlnLong() }
private fun readlnFloatArray(n: Int) = FloatArray(n) { readlnFloat() }
private fun readlnDoubleArray(n: Int) = DoubleArray(n) { readlnDouble() }

private fun readByteArray2d(rows: Int, cols: Int) = Array(rows) { readByteArray().also { require(it.size == cols) } }
private fun readShortArray2d(rows: Int, cols: Int) = Array(rows) { readShortArray().also { require(it.size == cols) } }
private fun readLongArray2d(rows: Int, cols: Int) = Array(rows) { readLongArray().also { require(it.size == cols) } }
private fun readIntArray2d(rows: Int, cols: Int) = Array(rows) { readIntArray().also { require(it.size == cols) } }
private fun readFloatArray2d(rows: Int, cols: Int) = Array(rows) { readFloatArray().also { require(it.size == cols) } }
private fun readDoubleArray2d(rows: Int, cols: Int) =
    Array(rows) { readDoubleArray().also { require(it.size == cols) } }

private fun isWhiteSpace(c: Char) = c in " \r\n\t"

// JVM-only targeting code follows next

// readString() via sequence is still slightly faster than Scanner
private fun readString() = generateSequence { System.`in`.read().toChar() }
    .dropWhile { isWhiteSpace(it) }.takeWhile { !isWhiteSpace(it) }.joinToString("")

private fun readByte() = readString().toByte()
private fun readShort() = readString().toShort()
private fun readInt() = readString().toInt()
private fun readLong() = readString().toLong()
private fun readFloat() = readString().toFloat()
private fun readDouble() = readString().toDouble()
private fun readBigInt(radix: Int = 10) = readString().toBigInteger(radix)
private fun readBigDecimal() = readString().toBigDecimal()

private fun readBytes(n: Int) = generateSequence { readByte() }.take(n)
private fun readShorts(n: Int) = generateSequence { readShort() }.take(n)
private fun readInts(n: Int) = generateSequence { readInt() }.take(n)
private fun readLongs(n: Int) = generateSequence { readLong() }.take(n)
private fun readFloats(n: Int) = generateSequence { readFloat() }.take(n)
private fun readDoubles(n: Int) = generateSequence { readDouble() }.take(n)

fun main() {
    repeat(readlnInt()) {
        val (d, k1 ,k2) = readIntArray()
        val days = readln()
        var c = 0
        var count = 0
        while (c < days.count() - 1) {
            if (days[c] == '1') {
                count += if (days[c + 1] == '1') {
                    k2
                } else {
                    k1
                }
                c += 2
            } else {
                c++
            }
        }
        if (c == (days.count() - 1) && days[c] == '1') {
            count += k1
        }
        println(count)
    }
}


private fun readln() = readLine()!!
private fun readlnByte() = readln().toByte()
private fun readlnShort() = readln().toShort()
private fun readlnInt() = readln().toInt()
private fun readlnLong() = readln().toLong()
private fun readlnFloat() = readln().toFloat()
private fun readlnDouble() = readln().toDouble()
private fun readlnBigInt(radix: Int = 10) = readln().toBigInteger(radix)
private fun readlnBigDecimal() = readln().toBigDecimal()

private fun lineSequence(limit: Int = Int.MAX_VALUE) = generateSequence { readLine() }.constrainOnce().take(limit)
private fun readlnStrings() = readln().split(' ')
private fun readlnBytes() = readlnStrings().map { it.toByte() }
private fun readlnShorts() = readlnStrings().map { it.toShort() }
private fun readlnInts() = readlnStrings().map { it.toInt() }
private fun readlnLongs() = readlnStrings().map { it.toLong() }
private fun readlnFloats() = readlnStrings().map { it.toFloat() }
private fun readlnDoubles() = readlnStrings().map { it.toDouble() }

private fun readByteArray() = readlnStrings().run { ByteArray(size) { get(it).toByte() } }
private fun readShortArray() = readlnStrings().run { ShortArray(size) { get(it).toShort() } }
private fun readIntArray() = readlnStrings().run { IntArray(size) { get(it).toInt() } }
private fun readLongArray() = readlnStrings().run { LongArray(size) { get(it).toLong() } }
private fun readFloatArray() = readlnStrings().run { FloatArray(size) { get(it).toFloat() } }
private fun readDoubleArray() = readlnStrings().run { DoubleArray(size) { get(it).toDouble() } }

private fun readlnByteArray(n: Int) = ByteArray(n) { readlnByte() }
private fun readlnShortArray(n: Int) = ShortArray(n) { readlnShort() }
private fun readlnIntArray(n: Int) = IntArray(n) { readlnInt() }
private fun readlnLongArray(n: Int) = LongArray(n) { readlnLong() }
private fun readlnFloatArray(n: Int) = FloatArray(n) { readlnFloat() }
private fun readlnDoubleArray(n: Int) = DoubleArray(n) { readlnDouble() }

private fun readByteArray2d(rows: Int, cols: Int) = Array(rows) { readByteArray().also { require(it.size == cols) } }
private fun readShortArray2d(rows: Int, cols: Int) = Array(rows) { readShortArray().also { require(it.size == cols) } }
private fun readLongArray2d(rows: Int, cols: Int) = Array(rows) { readLongArray().also { require(it.size == cols) } }
private fun readIntArray2d(rows: Int, cols: Int) = Array(rows) { readIntArray().also { require(it.size == cols) } }
private fun readFloatArray2d(rows: Int, cols: Int) = Array(rows) { readFloatArray().also { require(it.size == cols) } }
private fun readDoubleArray2d(rows: Int, cols: Int) =
    Array(rows) { readDoubleArray().also { require(it.size == cols) } }

private fun isWhiteSpace(c: Char) = c in " \r\n\t"

// JVM-only targeting code follows next

// readString() via sequence is still slightly faster than Scanner
private fun readString() = generateSequence { System.`in`.read().toChar() }
    .dropWhile { isWhiteSpace(it) }.takeWhile { !isWhiteSpace(it) }.joinToString("")

private fun readByte() = readString().toByte()
private fun readShort() = readString().toShort()
private fun readInt() = readString().toInt()
private fun readLong() = readString().toLong()
private fun readFloat() = readString().toFloat()
private fun readDouble() = readString().toDouble()
private fun readBigInt(radix: Int = 10) = readString().toBigInteger(radix)
private fun readBigDecimal() = readString().toBigDecimal()

private fun readBytes(n: Int) = generateSequence { readByte() }.take(n)
private fun readShorts(n: Int) = generateSequence { readShort() }.take(n)
private fun readInts(n: Int) = generateSequence { readInt() }.take(n)
private fun readLongs(n: Int) = generateSequence { readLong() }.take(n)
private fun readFloats(n: Int) = generateSequence { readFloat() }.take(n)
private fun readDoubles(n: Int) = generateSequence { readDouble() }.take(n)

fun main() {
    repeat(readInt()) {
        val (d, k1 ,k2) = readIntArray()
        val days = readln()
        var c = 0
        var count = 0
        while (c < days.count() - 1) {
            if (days[c] == '1') {
                count += if (days[c + 1] == '1') {
                    k2
                } else {
                    k1
                }
                c += 2
            } else {
                c++
            }
        }
        if (c == (days.count() - 1) && days[c] == '1') {
            count += k1
        }
        println(count)
    }
}


fun main() {
  val t = readLine()!!.toInt()
  repeat(t) {
    val (n, k1, k2) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!
    var last = 0
    var sum = 0
    for (i in 1..n) {
      val c = if (s[i - 1] == '1') minOf(k1, k2 - last) else 0
      sum += c
      last = c
    }
    println("$sum")
  }
}


fun main() {
    var num = readLine()!!.toInt()
    while (num != 0) {
        var (n, k1, k2) = readLine()!!.split(' ').map{ it.toInt()}
        val s = readLine()!!
        val list = s.toCharArray()
        var tre = 0
        var lec = 0
        var a = 0
        while (n != 0)
            if (list[a] == '1' && tre == 0){
                lec += k1
                a += 1
                n -= 1
                tre = 1
            }else if (list[a] == '0'){
                n -= 1
                a += 1
                tre = 0
            }else if (list[a] == '1' && tre == 1){
                n -= 1
                a += 1
                lec += (k2 - k1)
                tre = 1
            }
        println(lec)
        num -= 1
    }
}


fun main() {
    var num = readLine()!!.toInt()
    while (num != 0) {
        var (n, k1, k2) = readLine()!!.split(' ').map{ it.toInt()}
        val s = readLine()!!
        val list = s.toCharArray()
        var tre = 0
        var lec = 0
        var a = 0
        while (n != 0)
            if (list[a] == '1' && tre == 0){
                lec += k1
                a += 1
                n -= 1
                tre = 1
            }else if (list[a] == '0'){
                n -= 1
                a += 1
                tre = 0
            }else if (list[a] == '1' && tre == 1){
                n -= 1
                a += 1
                lec += (k2 - k1)
            }
        println(lec)
        num -= 1
    }
}


fun main() {
    var num = readLine()!!.toInt()
    while (num != 0) {
        var (n, k1, k2) = readLine()!!.split(' ').map{ it.toInt()}
        val s = readLine()!!
        val list = s.toCharArray()
        var tre = 0
        var lec = 0
        var a = 0
        while (n != 0)
            if (list[a] == '1' && tre == 0){
                lec += k1
                a += 1
                n -= 1
                tre = 1
            }else if (list[a] == '0'){
                n -= 1
                a += 1
                tre = 0
            }else if (list[a] == '1' && tre == 1){
                n -= 1
                a += 1
                lec += (k2 - k1)
                tre = 0
            }
        println(lec)
        num -= 1
    }
}


import java.lang.Integer.min

private fun readNumber(): Int {
    var number = -1
    while (true) {
        val byte = System.`in`.read()
        if (byte < 48 || byte > 57) {
            if (number > -1) return number
            continue
        }
        if (number == -1) number = 0
        number = number * 10 + (byte - 48)
    }
}

fun main() {
    val t = readNumber()
    repeat(t) {
        val n = readNumber()
        val k1 = readNumber()
        val k2 = readNumber()
        val days = readLine()!!
        val dayMax = min(k1, k2)
        var max = dayMax
        var total = 0
        repeat(n) { i ->
            if (days[i] == '0') {
                max = dayMax
            } else {
                total += max
                max = min(k1, k2 - max)
            }
        }
        println(total)
    }
}


import java.lang.Integer.min

fun main() {
    val t = readLine()!!.toInt()
    repeat(t) {
        val input = readLine()!!.split(' ')
        val n = input[0].toInt()
        val k1 = input[1].toInt()
        val k2 = input[2].toInt()
        val days = readLine()!!
        val dayMax = min(k1, k2)
        var max = dayMax
        var total = 0
        repeat(n) { i ->
            if (days[i] == '0') {
                max = dayMax
            } else {
                total += max
                max = min(k1, k2 - max)
            }
        }
        println(total)
    }
}


import java.lang.Integer.min

fun main() {
    val t = readLine()!!.toInt()
    repeat(t) {
        val input = readLine()!!.split(' ')
        val n = input[0].toInt()
        val k1 = input[1].toInt()
        val k2 = input[2].toInt()
        val days = readLine()!!.toInt(2)
        val dayMax = min(k1, k2)
        var max = dayMax
        var total = 0
        repeat(n) { i ->
            if (days.ushr(i).and(1) == 0) {
                max = dayMax
            } else {
                total += max
                max = min(k1, k2 - max)
            }
        }
        println(total)
    }
}


import java.lang.Integer.min

private fun readNumber(): Int {
    var number = -1
    while (true) {
        val byte = System.`in`.read().toChar()
        if (byte < '0' || byte > '9') {
            if ((byte == ' ' || byte == '\n') && number > -1) return number
            continue
        }
        if (number == -1) number = 0
        number = number * 10 + (byte - '0')
    }
}

fun main() {
    val t = readNumber()
    repeat(t) {
        val n = readNumber()
        val k1 = readNumber()
        val k2 = readNumber()
        val days = readLine()!!
        val dayMax = min(k1, k2)
        var max = dayMax
        var total = 0
        repeat(n) { i ->
            if (days[i] == '0') {
                max = dayMax
            } else {
                total += max
                max = min(k1, k2 - max)
            }
        }
        println(total)
    }
}


fun readIntValue() = readLine()!!.toInt()
fun readIntValues() = readLine()!!.split(" ").map{it.toInt()}
fun readStringValue() = readLine()!!.toString()
fun readStringValues() = readLine()!!.split(" ").map{it.toString()}

fun main() {
    var testCaseCount = readLine()!!.toInt()

    for (tc in 1..testCaseCount) {
        var (n, k1, k2) = readIntValues()
        var days = readStringValue()

        var prev = k1
        var m = 0

        for ((index, day) in days.withIndex()) {
            if (index == days.length-1 && day.toString() == "1") {
                m += if (prev == 0) {
                    k1
                } else {
                    k2 - prev
                }
                break
            }

            if (day.toString() == "0") {
                prev = 0

            } else {
                if (days[index+1].toString() == "0") {
                    m += k1
                    prev = 0
                } else {
                    m += k2 - prev
                    prev = k2 - prev
                }
            }
        }

        println("$m")
    }
}


fun readIntValue() = readLine()!!.toInt()
fun readIntValues() = readLine()!!.split(" ").map{it.toInt()}
fun readStringValue() = readLine()!!.toString()
fun readStringValues() = readLine()!!.split(" ").map{it.toString()}

fun main() {
    var testCaseCount = readLine()!!.toInt()

    for (tc in 1..testCaseCount) {
        var (n, k1, k2) = readIntValues()
        var days = readStringValue()

        var prev = 0
        var m = 0

        for ((index, day) in days.withIndex()) {
            if (index == days.length-1 && day.toString() == "1") {
                m += if (prev == 0) {
                    k1
                } else {
                    k2 - prev
                }
                break
            }

            if (day.toString() == "0") {
                prev = 0

            } else {
                if (prev == 0) {
                    m += k1
                    prev = k1
                } else {
                    m += k2 - prev
                    prev = k2 - prev
                }
            }

            //println(prev)
        }

        println("$m")
    }
}


fun readIntValue() = readLine()!!.toInt()
fun readIntValues() = readLine()!!.split(" ").map{it.toInt()}
fun readStringValue() = readLine()!!.toString()
fun readStringValues() = readLine()!!.split(" ").map{it.toString()}

fun main() {
    var testCaseCount = readLine()!!.toInt()

    for (tc in 1..testCaseCount) {
        var (n, k1, k2) = readIntValues()
        var days = readStringValue()

        var prev = k1
        var m = 0

        for ((index, day) in days.withIndex()) {
            if (index == days.length-1) {
                m += if (prev == 0) {
                    k1
                } else {
                    k2 - prev
                }
                break
            }

            if (day.toString() == "0") {
                prev = 0

            } else {
                if (days[index+1].toString() == "0") {
                    m += k1
                    prev = 0
                } else {
                    m += k2 - prev
                    prev = k2 - prev
                }
            }
        }

        println("$m")
    }
}


fun readIntValue() = readLine()!!.toInt()
fun readIntValues() = readLine()!!.split(" ").map{it.toInt()}
fun readStringValue() = readLine()!!.toString()
fun readStringValues() = readLine()!!.split(" ").map{it.toString()}

fun main() {
    var testCaseCount = readLine()!!.toInt()

    for (tc in 1..testCaseCount) {
        var (n, k1, k2) = readIntValues()
        var days = readStringValue()

        var prev = 0
        var m = 0

        for ((index, day) in days.withIndex()) {
            if (index == days.length-1 && day.toString() == "1") {
                m += if (prev == 0) {
                    k1
                } else {
                    if (k2 - prev > k1) k1 else k2-prev
                }
                break
            }

            if (day.toString() == "0") {
                prev = 0

            } else {
                if (prev == 0) {
                    m += k1
                    prev = k1
                } else {
                    var delta = k2 - prev
                    if (k2 - prev > k1) {
                        delta = k1
                    }
                    m += delta
                    prev = delta
                }
            }

            println(prev)
        }

        println("$m")
    }
}


fun readIntValue() = readLine()!!.toInt()
fun readIntValues() = readLine()!!.split(" ").map{it.toInt()}
fun readStringValue() = readLine()!!.toString()
fun readStringValues() = readLine()!!.split(" ").map{it.toString()}

fun main() {
    var testCaseCount = readLine()!!.toInt()

    for (tc in 1..testCaseCount) {
        var (n, k1, k2) = readIntValues()
        var days = readStringValue()

        var prev = 0
        var m = 0

        for ((index, day) in days.withIndex()) {
            if (index == days.length-1 && day.toString() == "1") {
                m += if (prev == 0) {
                    k1
                } else {
                    k2 - prev
                }
                break
            }

            if (day.toString() == "0") {
                prev = 0

            } else {
                if (prev == 0) {
                    m += k1
                    prev = k1
                } else {
                    var delta = k2 - prev
                    if (k2 - prev > k1) {
                        delta = k1
                    }
                    m += delta
                    prev = delta
                }
            }

            //println(prev)
        }

        println("$m")
    }
}


fun readIntValue() = readLine()!!.toInt()
fun readIntValues() = readLine()!!.split(" ").map{it.toInt()}
fun readStringValue() = readLine()!!.toString()
fun readStringValues() = readLine()!!.split(" ").map{it.toString()}

fun main() {
    var testCaseCount = readLine()!!.toInt()

    for (tc in 1..testCaseCount) {
        var (n, k1, k2) = readIntValues()
        var days = readStringValue()

        var prev = 0
        var m = 0

        for ((index, day) in days.withIndex()) {
            if (index == days.length-1 && day.toString() == "1") {
                m += if (prev == 0) {
                    k1
                } else {
                    if (k2 - prev > k1) k1 else k2-prev
                }
                break
            }

            if (day.toString() == "0") {
                prev = 0
            } else {
                if (prev == 0) {
                    m += k1
                    prev = k1
                } else {
                    var delta = k2 - prev
                    if (k2 - prev > k1) {
                        delta = k1
                    }
                    m += delta
                    prev = delta
                }
            }

            //println(prev)
        }

        println("$m")
    }
}


fun readIntValue() = readLine()!!.toInt()
fun readIntValues() = readLine()!!.split(" ").map{it.toInt()}
fun readStringValue() = readLine()!!.toString()
fun readStringValues() = readLine()!!.split(" ").map{it.toString()}

fun main() {
    var testCaseCount = readLine()!!.toInt()

    for (tc in 1..testCaseCount) {
        var (n, k1, k2) = readIntValues()
        var days = readStringValue()

        var prev = 0
        var m = 0

        for ((index, day) in days.withIndex()) {
            if (index == days.length-1 && day.toString() == "1") {
                m += if (prev == 0) {
                    k1
                } else {
                    k2 - prev
                }
                break
            }

            if (day.toString() == "0") {
                prev = 0

            } else {
                if (prev == 0) {
                    if (days[index+1].toString() == "0") {
                        m += k1
                        prev = 0
                    } else {
                        m += k2 - prev
                        prev = k2 - prev
                    }
                } else {
                    m += k2 - prev
                    prev = k2 - prev
                }
            }
        }

        println("$m")
    }
}


fun readIntValue() = readLine()!!.toInt()
fun readIntValues() = readLine()!!.split(" ").map{it.toInt()}
fun readStringValue() = readLine()!!.toString()
fun readStringValues() = readLine()!!.split(" ").map{it.toString()}

fun main() {
    var testCaseCount = readLine()!!.toInt()

    for (tc in 1..testCaseCount) {
        var (n, k1, k2) = readIntValues()
        var days = readStringValue()

        var prev = 0
        var m = 0

        for ((index, day) in days.withIndex()) {
            if (index == days.length-1 && day.toString() == "1") {
                m += if (prev == 0) {
                    k1
                } else {
                    k2 - prev
                }
                break
            }

            if (day.toString() == "0") {
                prev = 0

            } else {
                if (prev == 0) {
                    if (days[index+1].toString() == "0") {
                        m += k1
                        prev = 0
                    } else {
                        m += k1
                        prev = k1
                    }
                } else {
                    m += k2 - prev
                    prev = k2 - prev
                }
            }

            //println(prev)
        }

        println("$m")
    }
}


fun main() {
    getMaxLectures()
}
fun getMaxLectures() {
    val T = readLine()!!.toInt()

    repeat(T) {
        val (n, k1, k2) = readLine()!!.split(" ").map { it.toLong() }

        val schedule = readLine()!!

        var maxLec: Long = 0L

        var lastAssigned = 0L
        schedule.forEachIndexed { index, c ->

            if (c == '1') {
                if (2*k1 <= k2) {
                    maxLec += k1
                } else if (k1 == k2){
                    if (index == 0) {
                        maxLec += k1
                        lastAssigned = k1
                    } else if (schedule[index-1] != '1' && lastAssigned == 0L) {
                        maxLec += k1
                        lastAssigned = k1
                    } else {
                        lastAssigned = 0
                    }
                } else if (2*k1 > k2) {
                    if (index == 0) {
                        maxLec += k1
                        lastAssigned = k1
                    } else if (schedule[index-1] == '1') {
                        maxLec += (k2 - lastAssigned)
                        lastAssigned = k2 - lastAssigned
                    } else {
                        maxLec += k1
                        lastAssigned = k1
                    }
                }
            } else {
                lastAssigned = 0
            }
        }
        println(maxLec)
    }
}


fun main() {
    getMaxLectures()
}
fun getMaxLectures() {
    val T = readLine()!!.toInt()

    repeat(T) {
        val (n, k1, k2) = readLine()!!.split(" ").map { it.toInt() }

        val schedule = readLine()!!

        var maxLec: Long = 0L

        var lastAssigned = 0
        schedule.forEachIndexed { index, c ->

            if (c == '1') {
                if (2*k1 <= k2) {
                    maxLec += k1
                } else if (k1 >= k2){
                    if (index == 0) {
                        maxLec += k2
                        lastAssigned = k2
                    } else if (schedule[index-1] != '1') {
                        maxLec += k2
                    }
                } else if (2*k1 > k2) {
                    if (index == 0) {
                        maxLec += k1
                        lastAssigned = k1
                    } else if (schedule[index-1] == '1') {
                        maxLec += (k2 - lastAssigned)
                        lastAssigned = k2 - lastAssigned
                    } else {
                        maxLec += k1
                        lastAssigned = k1
                    }
                }
            } else {
                lastAssigned = 0
            }
        }
        println(maxLec)
    }
}


fun main() {
    getMaxLectures()
}
fun getMaxLectures() {
    val T = readLine()!!.toInt()

    repeat(T) {
        val (n, k1, k2) = readLine()!!.split(" ").map { it.toInt() }

        val schedule = readLine()!!

        var maxLec = 0

        var lastAssigned = 0
        schedule.forEachIndexed { index, c ->

            if (c == '1') {

                if (2*k1 <= k2) {
                    maxLec += k1
                    lastAssigned = k1
                } else if (k1 >= k2){
                    if (index == 0) {
                        maxLec += k2
                        lastAssigned = k2
                    } else if (schedule[index-1] != '1') {
                        maxLec += k2
                        lastAssigned = k2
                    }
                } else if (2*k1 > k2) {
                    if (index == 0) {
                        maxLec += k1
                        lastAssigned = k1
                    } else if (schedule[index-1] == '1') {
                        maxLec += k2 - lastAssigned
                        lastAssigned = k2 - lastAssigned
                    } else {
                        maxLec += k1
                        lastAssigned = k1
                    }
                }
            } else {
                lastAssigned = 0
            }
        }
        println(maxLec)
    }
}


fun main() {
    getMaxLectures()
}
fun getMaxLectures() {
    val T = readLine()!!.toInt()

    repeat(T) {
        val (n, k1, k2) = readLine()!!.split(" ").map { it.toLong() }

        val schedule = readLine()!!

        var maxLec: Long = 0L

        var lastAssigned = 0L
        schedule.forEachIndexed { index, c ->

            if (c == '1') {
                if (2*k1 <= k2) {
                    maxLec += k1
                } else if (k1 == k2){
                    if (index == 0) {
                        maxLec += k1
                        lastAssigned = k1
                    } else if (schedule[index-1] != '1') {
                        maxLec += k1
                        lastAssigned = k1
                    } else {
                        if (lastAssigned == 0L) {
                            maxLec += k1
                            lastAssigned = k1
                        } else {
                            lastAssigned = 0
                        }
                    }
                } else if (2*k1 > k2) {
                    if (index == 0) {
                        maxLec += k1
                        lastAssigned = k1
                    } else if (schedule[index-1] == '1') {
                        maxLec += (k2 - lastAssigned)
                        lastAssigned = k2 - lastAssigned
                    } else {
                        maxLec += k1
                        lastAssigned = k1
                    }
                }
            } else {
                lastAssigned = 0
            }
        }
        println(maxLec)
    }
}


import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)

    val lines = scan.nextLine().trim().toInt()

    val results = Array(lines, {0})

    for (i in 0 until lines) {
        val numbers = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
        val s = scan.nextLine().trim()

        results[i] = calculateLectures(numbers[0], numbers[1], numbers[2], s)
    }

    for (result in results) {
        println(result)
    }
}

fun calculateLectures(n : Int, k1 : Int, k2 : Int, s : String) : Int {
    var lectureDayCount : Int = 0
    var max : Int = 0

    for(c in s) {
        if (c == '1') {
            lectureDayCount++
        }
        else {
            if (lectureDayCount > 0)
                max += calculateMax(lectureDayCount, k1, k2)

            lectureDayCount = 0
        }
    }

    if (lectureDayCount > 0)
        max += calculateMax(lectureDayCount, k1, k2)

    return max
}

fun calculateMax(count : Int, k1 : Int, k2 : Int) : Int {
    if (count == 0) return 0
    if (count == 1) return k1

    return (ceil(count / 2.0) * k1).toInt() + (floor(count / 2.0) * (k2 - k1)).toInt()
}


import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)

    val lines = scan.nextLine().trim().toInt()

    val results = Array(lines, {0})

    for (i in 0 until lines) {
        val numbers = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
        val s = scan.nextLine().trim()

        if (numbers[2] < numbers[1])
            results[i] = 0
        else
            results[i] = calculateLectures(numbers[0], numbers[1], numbers[2], s)
    }

    if (results.count() == 0)
        println("0")
    else {
        for (result in results) {
            println(result)
        }
    }
}

fun calculateLectures(n : Int, k1 : Int, k2 : Int, s : String) : Int {
    var lectureDayCount : Int = 0
    var max : Int = 0

    for(c in s) {
        if (c == '1') {
            lectureDayCount++
        }
        else {
            if (lectureDayCount > 0)
                max += calculateMax(lectureDayCount, k1, k2)

            lectureDayCount = 0
        }
    }

    if (lectureDayCount > 0)
        max += calculateMax(lectureDayCount, k1, k2)

    return max
}

fun calculateMax(count : Int, k1 : Int, k2 : Int) : Int {
    if (count == 0) return 0
    if (count == 1) return k1

    return (ceil(count / 2.0) * k1).toInt() + (floor(count / 2.0) * (k2 - k1)).toInt()
}


import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)

    val lines = scan.nextLine().trim().toInt()

    val results = Array(lines, {0})

    for (i in 0 until lines) {
        val numbers = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
        val s = scan.nextLine().trim()

        results[i] = calculateLectures(numbers[0], numbers[1], numbers[2], s)
    }

    if (results.count() == 0)
        println("0")
    else {
        for (result in results) {
            println(result)
        }
    }
}

fun calculateLectures(n : Int, k1 : Int, k2 : Int, s : String) : Int {
    var lectureDayCount : Int = 0
    var max : Int = 0

    for(c in s) {
        if (c == '1') {
            lectureDayCount++
        }
        else {
            if (lectureDayCount > 0)
                max += calculateMax(lectureDayCount, k1, k2)

            lectureDayCount = 0
        }
    }

    if (lectureDayCount > 0)
        max += calculateMax(lectureDayCount, k1, k2)

    return max
}

fun calculateMax(count : Int, k1 : Int, k2 : Int) : Int {
    if (count == 0) return 0
    if (count == 1) return k1

    return (ceil(count / 2.0) * k1).toInt() + (floor(count / 2.0) * (k2 - k1)).toInt()
}


import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)

    val lines = scan.nextLine().trim().toInt()

    val results = Array(lines, {0})

    for (i in 0 until lines) {
        val numbers = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
        val s = scan.nextLine().trim()

        if (numbers[2] < numbers[1])
            results[i] = 0
        else
            results[i] = calculateLectures(numbers[0], numbers[1], numbers[2], s)
    }

    if (results.count() == 0)
        println("0")
    else {
        for (result in results) {
            println(result)
        }
    }
}

fun calculateLectures(n : Int, k1 : Int, k2 : Int, s : String) : Int {
    var lectureDayCount : Int = 0
    var max : Int = 0

    for(c in s) {
        if (c == '1') {
            lectureDayCount++
        }
        else {
            if (lectureDayCount > 0)
                max += calculateMax(lectureDayCount, k1, k2)

            lectureDayCount = 0
        }
    }

    if (lectureDayCount > 0)
        max += calculateMax(lectureDayCount, k1, k2)

    return max
}

fun calculateMax(count : Int, k1 : Int, k2 : Int) : Int {
    if (count == 0) return 0
    if (count == 1) return k1

    if (k2 >= k1 * 2)
        return count * k1

    return (ceil(count / 2.0) * k1).toInt() + (floor(count / 2.0) * (k2 - k1)).toInt()
}


fun main(){
    var t = readLine()!!.toInt()
    for (j in 1..t){
        var (n, k1, k2) = readLine()!!.split(" ").map{it.toInt()};
        var s = readLine()!!
        var cnt : Long = 0;
        var arr : Long = 0;
        for (c in s){
            if (c == '1'){
                cnt++;
            }
            else{
                arr += (k2 * (cnt / 2) + k1 * (cnt % 2));
                cnt = 0;
            }
        }
        arr += (k2 * (cnt / 2) + k1 * (cnt % 2));
        println(arr);
    }
}


fun main(){
    var t = readLine()!!.toInt()
    for (j in 1..t){
        var (n, k1, k2) = readLine()!!.split(" ").map{it.toLong()};
        k2 = minOf(k2, 2 * k1);
        var s = readLine()!!
        var cnt : Long = 0;
        var arr : Long = 0;
        for (c in s){
            if (c == '1'){
                cnt++;
            }
            else{
                arr += (k2 * (cnt / 2) + k1 * (cnt % 2));
                cnt = 0;
            }
        }
        arr += (k2 * (cnt / 2) + k1 * (cnt % 2));
        println(arr);
    }
}


fun main(){
    var t = readLine()!!.toInt()
    for (j in 1..t){
        var (n, k1, k2) = readLine()!!.split(" ").map{it.toLong()};
        var s = readLine()!!
        var cnt : Long = 0;
        var arr : Long = 0;
        for (c in s){
            if (c == '1'){
                cnt++;
            }
            else{
                arr += (k2 * (cnt / 2) + k1 * (cnt % 2));
                cnt = 0;
            }
        }
        arr += (k2 * (cnt / 2) + k1 * (cnt % 2));
        println(arr);
    }
}


fun main(){
    var t = readLine()!!.toInt()
    for (j in 1..t){
        var (n, k1, k2) = readLine()!!.split(" ").map{it.toInt()};
        var s = readLine()!!
        var cnt : Int = 0;
        var arr : Int = 0;
        for (c in s){
            if (c == '1'){
                cnt++;
            }
            else{
                arr += (k2 * (cnt / 2) + k1 * (cnt % 2));
                cnt = 0;
            }
        }
        arr += (k2 * (cnt / 2) + k1 * (cnt % 2));
        println(arr);
    }
}


import java.io.*

private val env = HashSet<String>();
private lateinit var reader: BufferedReader;

fun main(args: Array<String>) {
    args.forEach { e -> run {
            env.add(e)
        } };
    beforeInvocation();
    run();
    afterInvocation();
}

fun ins(): InputStream {
    return if (env.contains("DEBUG")) FileInputStream("test.in");
    else System.`in`;
}

fun beforeInvocation() {
    reader = BufferedReader(InputStreamReader(ins()));
}

fun afterInvocation() {
}

fun run() {

    for (test in 0 until reader.readLine().toInt()) {
        var (n, k1, k2) = reader.readLine().split(" ").map { it.toInt() }
        var s = reader.readLine()
        var ans = 0.toLong()
        var len = 0
        for(i in s.indices){
            if(s[i] == '0'){
                ans += if(len > 1) len / 2 * k2 + (len%2)*(k2/2+(k2%2)) else k1
                len = 0
            }
            else{
                len++
            }
        }
        ans += if(len > 1) len / 2 * k2 + (len%2)*(k2/2+(k2%2)) else k1
        println("$ans\n")
    }

}