// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

// void solve() {
//     int n, k, mn = INF;
//     cin >> n >> k;
//     vi c(n);
//     REP(i, 0, n) cin >> c[i];

//     REP(i, 1, 101) {
//         int ans = 0, pre = 0;
//         REP(j, 0, n) {
//             if(c[j] == i) {
//                 ans += (j - pre + k - 1) / k;
//                 pre = j + 1;
//             }
//             if(j == n - 1)
//                 ans += (n - pre + k - 1) / k;
//         }
//         if(ans) mn = min(mn, ans);
//     }

//     cout << mn << "\n";
// }

void solve() {
    int n, p, k, x, y, cnt = 0, mn = INF;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, INF);

    REP(i, 0, k) {
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
    }

    REP(i, k, n) {
        if(a[i-k] == '0') cnt++;
        dp[i] = dp[i-k] + k * y - cnt * x;
    }

    REP(i, 0, n - p + 1) mn = min(dp[i], mn);
    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

void solve() {
    int n, p, k, x, y, cnt = 0, mn = INF;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, 0);

    REP(i, 0, k) {
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
    }

    REP(i, k, n) {
        if(a[i-k] == '0') cnt++;
        dp[i] = dp[i-k] + (i - k + 1) * y - cnt * x;
    }

    REP(i, 0, n) if(dp[i] >= 0) mn = min(dp[i], mn);
    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

// void solve() {
//     int n, k, mn = INF;
//     cin >> n >> k;
//     vi c(n);
//     REP(i, 0, n) cin >> c[i];

//     REP(i, 1, 101) {
//         int ans = 0, pre = 0;
//         REP(j, 0, n) {
//             if(c[j] == i) {
//                 ans += (j - pre + k - 1) / k;
//                 pre = j + 1;
//             }
//             if(j == n - 1)
//                 ans += (n - pre + k - 1) / k;
//         }
//         if(ans) mn = min(mn, ans);
//     }

//     cout << mn << "\n";
// }

void solve() {
    int n, p, k, x, y, cnt = 0, mn = INF;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, INF);

    REP(i, 0, k) {
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
    }

    REP(i, k, n) {
        if(a[i-k] == '0') cnt++;
        dp[i] = dp[i-k] + k * y - cnt * x;
    }

    REP(i, 0, n) mn = min(dp[i], mn);
    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

void solve() {
    int n, p, k, x, y, mn = INF;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, INF), cnt(k, 0);

    REP(i, 0, k) {
        if(i == n - p + 1) break;
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
        mn = min(mn, dp[i]);
    }

    REP(i, k, n - p + 1) {
        if(a[p + i - k - 1] == '0') cnt[i % k]++;
        dp[i] = dp[i-k] + k * y;
        mn = min(mn, dp[i] - cnt[i % k] * x);
    }

    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

void solve() {
    int n, p, k, x, y;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, 0);

    REP(i, 0, k) {
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
    }

    int j = 0, mn = INF;
    REP(i, k, n) {
        if(i % k == 0) j++;
        dp[i] = dp[i-k] + (i - k + 1) * y - j * x;
    }

    REP(i, 0, n) mn = min(dp[i], mn);
    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

void solve() {
    int n, p, k, x, y, cnt = 0, mn = INF;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, INF);

    REP(i, 0, k) {
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
    }

    REP(i, k, n) {
        if(a[i-k] == '0') cnt++;
        dp[i] = dp[i-k] + (i - k + 1) * y - cnt * x;
    }

    REP(i, 0, n - p + 1) mn = min(dp[i], mn);
    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

void solve() {
    int n, p, k, x, y, cnt = 0, mn = INF;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, 0);

    REP(i, 0, k) {
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
    }

    REP(i, k, n) {
        if(a[i-k] == '0') cnt++;
        dp[i] = dp[i-k] + k * y - cnt * x;
    }

    REP(i, 0, n) mn = min(dp[i], mn);
    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

void solve() {
    int n, p, k, x, y, mn = INF;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, INF), cnt(k, 0);

    REP(i, 0, k) {
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
        mn = min(mn, dp[i]);
    }

    REP(i, k, n - p + 1) {
        if(a[p + i - k - 1] == '0') cnt[i % k]++;
        dp[i] = dp[i-k] + k * y;
        mn = min(mn, dp[i] - cnt[i % k] * x);
    }

    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

void solve() {
    int n, p, k, x, y, cnt = 0;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, INF);

    REP(i, 0, k) {
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
    }

    REP(i, k, n) {
        if(a[i-k] == '0') cnt++;
        dp[i] = dp[i-k] + k * y - cnt * x;
    }

    int mn = dp[0];
    REP(i, 0, n - p) mn = min(dp[i], mn);
    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

void solve() {
    int n, p, k, x, y, mn = INF;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, INF), cnt(k, 0);

    REP(i, 0, k) {
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
        mn = min(mn, dp[i]);
    }

    REP(i, k, n) {
        if(a[p + i - k - 1] == '0') cnt[i % k]++;
        dp[i] = dp[i-k] + k * y;
        mn = min(mn, dp[i] - cnt[i % k] * x);
    }
    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define BOOST() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define FILL(v, x) memset(v, x, sizeof(v))
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(), (v).end()
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}
// template<class T> using ordered_set =
//     tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 1LL << 60;
const int N   = 3e5 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

// void solve() {
//     int n, k, mn = INF;
//     cin >> n >> k;
//     vi c(n);
//     REP(i, 0, n) cin >> c[i];

//     REP(i, 1, 101) {
//         int ans = 0, pre = 0;
//         REP(j, 0, n) {
//             if(c[j] == i) {
//                 ans += (j - pre + k - 1) / k;
//                 pre = j + 1;
//             }
//             if(j == n - 1)
//                 ans += (n - pre + k - 1) / k;
//         }
//         if(ans) mn = min(mn, ans);
//     }

//     cout << mn << "\n";
// }

void solve() {
    int n, p, k, x, y;
    string a;
    cin >> n >> p >> k >> a >> x >> y;
    vi dp(n, INF), cnt(k, 0);

    REP(i, 0, k) {
        dp[i] = i * y;
        for(int j = p + i - 1; j < n; j += k)
            if(a[j] == '0') dp[i] += x;
    }

    REP(i, k, n) {
        if(a[i-k] == '0') cnt[i % k]++;
        dp[i] = dp[i-k] + k * y - cnt[i % k] * x;
    }

    int mn = dp[0];
    REP(i, 0, n - p) mn = min(dp[i], mn);
    cout << mn << "\n";
}

int32_t main() {
    BOOST();
    int t = 0;
    if (!t) cin >> t;

    REP(_, 1, t + 1) {
        // cout << "Case #" << _ << ": ";
        solve();
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    //taskkill /im first.exe /t /f
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k;
        cin>>n>>p>>k;
        string a;
        cin>>a;
        a=" "+a;
        ll x,y;
        cin>>x>>y;
        ll min1=1000000000000000;
        int index;
        ll z=k;
        for(int i=0;i<=k;i++){
            ll ans=i*y;
            for(int j=i+p;j<=n;j+=k){
                if(a[j]=='0') ans+=x;
            }
            if(min1>ans){
                min1=ans;
                index=i;
            }
        }
        cout<<min1<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    //taskkill /im first.exe /t /f
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k;
        cin>>n>>p>>k;
        string a;
        cin>>a;
        a=" "+a;
        ll x,y;
        cin>>x>>y;
        ll min1=1000000000000000;
        int index;
        ll z=n/k;
        for(int i=0;i<=min(z,n);i++){
            ll ans=i*y;
            //cout<<ans<<" ";
            for(int j=i+p;j<=n;j+=k){
                //cout<<j<<" ";
                if(a[j]=='0') ans+=x;
            }
            //cout<<"\n";
            if(min1>ans){
                min1=ans;
                index=i;
            }
        }
        //cout<<index<<" ";
        cout<<min1<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    //taskkill /im first.exe /t /f
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k;
        cin>>n>>p>>k;
        string a;
        cin>>a;
        n=a.size();
        a=" "+a;
        ll x,y;
        cin>>x>>y;
        ll min1=1000000000000000;
        int index;
        ll z=k;
        for(int i=0;i<=min(n-p,max(2000ll,k));i++){
            ll ans=i*y;
            for(int j=i+p;j<=n;j+=k){
                if(a[j]=='0') ans+=x;
            }
            if(min1>ans){
                min1=ans;
                index=i;
            }
        }
        cout<<min1<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    //taskkill /im first.exe /t /f
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k;
        cin>>n>>p>>k;
        string a;
        cin>>a;
        n=a.size();
        a=" "+a;
        ll x,y;
        cin>>x>>y;
        ll min1=1000000000000000;
        ll cnt=0;
        ll i=p;
        map<ll,ll> m;
        while(i<=p+k-1 && i<=n){
            ll ans=cnt*y;
            m[i]=0;
            for(int j=i;j<=n;j+=k){
                if(a[j]=='0') m[i]++;
            }
            i++;
        }
        // for(auto i: m){
        //     cout<<i.first<<" "<<i.second<<"\n";
        // }
        int turn=0,q=p;
        for(ll i=p;i<=n;i++)
        {
            if(cnt==k){
                cnt=0;
                q=p;
            }
            ll ans=turn*y;
            ans+=(m[q]*x);
            if(a[turn+p]=='0') m[q]--;
            turn++;
            cnt++;
            q++;
            //cout<<ans<<"\n";
            min1=min(min1,ans);
        }
        cout<<min1<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    //taskkill /im first.exe /t /f
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k;
        cin>>n>>p>>k;
        string a;
        cin>>a;
        a=" "+a;
        ll x,y;
        cin>>x>>y;
        ll min1=1000000000000000;
        int index;
        for(int i=0;i<=min(100ll,n);i++){
            ll ans=i*y;
            //cout<<ans<<" ";
            for(int j=i+p;j<=n;j+=k){
                //cout<<j<<" ";
                if(a[j]=='0') ans+=x;
            }
            //cout<<"\n";
            if(min1>ans){
                min1=ans;
                index=i;
            }
        }
        //cout<<index<<" ";
        cout<<min1<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    //taskkill /im first.exe /t /f
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k;
        cin>>n>>p>>k;
        string a;
        cin>>a;
        a=" "+a;
        ll x,y;
        cin>>x>>y;
        ll min1=1000000000000000;
        int index;
        ll z=k;
        for(int i=0;i<=min(n-p,max(1000ll,k));i++){
            ll ans=i*y;
            for(int j=i+p;j<=n;j+=k){
                if(a[j]=='0') ans+=x;
            }
            if(min1>ans){
                min1=ans;
                index=i;
            }
        }
        cout<<min1<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    //taskkill /im first.exe /t /f
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k;
        cin>>n>>p>>k;
        string a;
        cin>>a;
        a=" "+a;
        ll x,y;
        cin>>x>>y;
        ll min1=1000000000000000;
        int index;
        ll z=k;
        for(int i=0;i<=min(n-p,max(5000ll,k));i++){
            ll ans=i*y;
            for(int j=i+p;j<=n;j+=k){
                if(a[j]=='0') ans+=x;
            }
            if(min1>ans){
                min1=ans;
                index=i;
            }
        }
        cout<<min1<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    //taskkill /im first.exe /t /f
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k;
        cin>>n>>p>>k;
        string a;
        cin>>a;
        a=" "+a;
        ll x,y;
        cin>>x>>y;
        ll min1=1000000000000000;
        int index;
        ll z=k;
        for(int i=0;i<=min(n-p,max(1500ll,k));i++){
            ll ans=i*y;
            for(int j=i+p;j<=n;j+=k){
                if(a[j]=='0') ans+=x;
            }
            if(min1>ans){
                min1=ans;
                index=i;
            }
        }
        cout<<min1<<"\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    //taskkill /im first.exe /t /f
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t;
    cin>>t;
    while(t--)
    {
        ll n,p,k;
        cin>>n>>p>>k;
        string a;
        cin>>a;
        n=a.size();
        a=" "+a;
        ll x,y;
        cin>>x>>y;
        ll min1=1000000000000000;
        ll cnt=0;
        ll i=p;
        while(i<=p+k && i<=n){
            ll ans=cnt*y;
            for(int j=i;j<=n;j+=k){
                if(a[j]=='0') ans+=x;
            }
            if(min1>ans){
                min1=ans;
            }
            i++;
            cnt++;
        }
        cout<<min1<<"\n";
    }
}


#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
#define int long long
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int n,p,k;
string s;
int x,y;
int dp[100005][3];
int solve(int pos,int flag)
{
     int &ans=dp[pos][flag];
     if(ans!=-1) return ans;
      if(pos==n)
      {
          if(flag==0) return 1e15;
          return 0;
      }

     if(flag)
     {
           int op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
           return ans=op2;
     }
     else
     {
         int op1,op2;
         op1=y+solve(pos+1,0);
        op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
        return ans=min(op1,op2);
     }
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int t;
     cin>>t;
     while(t--)
     {
          cin>>n>>p>>k>>s>>x>>y;
          for(int i=0; i<n; i++)
            for(int j=0; j<=1; j++)
            dp[i][j]=-1;
          int ans=solve(p-1,0);
          cout<<ans<<endl;

     }
}


#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
#define int long long
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int n,p,k;
string s;
int x,y;
int dp[300009][5];
int solve(int pos,int flag)
{
     int &ans=dp[pos][flag];
     if(ans!=-1) return ans;
      if(pos>=n)
      {
          if(flag==0) return 1e14;
        else   return 0;
      }

     if(flag)
     {
           int op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
           return ans=op2;
     }
     else
     {
         int op1,op2;
         op1=y+solve(pos+1,0);
        op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
        return ans=min(op1,op2);
     }
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int t;
     cin>>t;
     while(t--)
     {
          cin>>n>>p>>k>>s>>x>>y;
        memset(dp,-1,sizeof dp);
          int ans=solve(p-1,0);
          cout<<ans<<endl;

     }
}


#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
#define int long long
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int n,p,k;
string s;
int x,y;
int dp[100005][3];
int solve(int pos,int flag)
{
     int &ans=dp[pos][flag];
     if(ans!=-1) return ans;
      if(pos>=n)
      {
          if(flag==0) return 1e17;
        else   return 0;
      }

     if(flag)
     {
           int op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
           return ans=op2;
     }
     else
     {
         int op1,op2;
         op1=y+solve(pos+1,0);
        op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
        return ans=min(op1,op2);
     }
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int t;
     cin>>t;
     while(t--)
     {
          cin>>n>>p>>k>>s>>x>>y;
          for(int i=0; i<n; i++)
            for(int j=0; j<=1; j++)
            dp[i][j]=-1;
          int ans=solve(p-1,0);
          cout<<ans<<endl;

     }
}


#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
#define int long long
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int n,p,k;
string s;
int x,y;
int dp[100005][3];
int solve(int pos,int flag)
{
     int &ans=dp[pos][flag];
     if(ans!=-1) return ans;
      if(pos==n)
      {
          if(flag==0) return 1e18;
          return 0;
      }

     if(flag)
     {
           int op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
           return ans=op2;
     }
     else
     {
         int op1,op2;
         op1=y+solve(pos+1,0);
        op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
        return ans=min(op1,op2);
     }
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int t;
     cin>>t;
     while(t--)
     {
          cin>>n>>p>>k>>s>>x>>y;
          for(int i=0; i<n; i++)
            for(int j=0; j<=1; j++)
            dp[i][j]=-1;
          int ans=solve(p-1,0);
          cout<<ans<<endl;

     }
}


#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
#define int long long
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int n,p,k;
string s;
int x,y;
int dp[100005][3];
int solve(int pos,int flag)
{
     int &ans=dp[pos][flag];
     if(ans!=-1) return ans;
      if(pos>=n)
      {
          if(flag==0) return 1e15;
          return 0;
      }

     if(flag)
     {
           int op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
           return ans=op2;
     }
     else
     {
         int op1,op2;
         op1=y+solve(pos+1,0);
        op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
        return ans=min(op1,op2);
     }
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int t;
     cin>>t;
     while(t--)
     {
          cin>>n>>p>>k>>s>>x>>y;
          for(int i=0; i<n; i++)
            for(int j=0; j<=1; j++)
            dp[i][j]=-1;
          int ans=solve(p-1,0);
          cout<<ans<<endl;

     }
}


#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
#define int long long
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int n,p,k;
string s;
int x,y;
int dp[100005][3];
int solve(int pos,int flag)
{
     int &ans=dp[pos][flag];
     if(ans!=-1) return ans;
     if(pos>=n) return 0;
    // if(flag==0 && n-pos<p) return 1e15;
     if(flag)
     {
           int op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
           return ans=op2;
     }
     else
     {
         int op1,op2;
         op1=y+solve(pos+1,0);
        op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
        return ans=min(op1,op2);
     }
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int t;
     cin>>t;
     while(t--)
     {
          cin>>n>>p>>k>>s>>x>>y;
          for(int i=0; i<=n+4; i++)
            for(int j=0; j<=1; j++)
            dp[i][j]=-1;
          int ans=solve(p-1,0);
          cout<<ans<<endl;

     }
}


#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
#define int long long
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int n,p,k;
string s;
int x,y;
int dp[100009][5];
int solve(int pos,int flag)
{
     int &ans=dp[pos][flag];
     if(ans!=-1) return ans;
      if(pos>=n)
      {
          if(flag==0) return 1e14;
        else   return 0;
      }

     if(flag)
     {
           int op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
           return ans=op2;
     }
     else
     {
         int op1,op2;
         op1=y+solve(pos+1,0);
        op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
        return ans=min(op1,op2);
     }
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int t;
     cin>>t;
     while(t--)
     {
          cin>>n>>p>>k>>s>>x>>y;
          for(int i=0; i<=n+5; i++)
            for(int j=0; j<=2; j++)
            dp[i][j]=-1;
          int ans=solve(p-1,0);
          cout<<ans<<endl;

     }
}


#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
#define int long long
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int n,p,k;
string s;
int x,y;
int dp[100005][3];
int solve(int pos,int flag)
{
     int &ans=dp[pos][flag];
     if(ans!=-1) return ans;
      if(pos>=n)
      {
          if(flag==0) return 1e10;
          return 0;
      }

     if(flag)
     {
           int op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
           return ans=op2;
     }
     else
     {
         int op1,op2;
         op1=y+solve(pos+1,0);
        op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
        return ans=min(op1,op2);
     }
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int t;
     cin>>t;
     while(t--)
     {
          cin>>n>>p>>k>>s>>x>>y;
          for(int i=0; i<n; i++)
            for(int j=0; j<=1; j++)
            dp[i][j]=-1;
          int ans=solve(p-1,0);
          cout<<ans<<endl;

     }
}


#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
#define int long long
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int n,p,k;
string s;
int x,y;
int dp[300009][5];
int solve(int pos,int flag)
{
     int &ans=dp[pos][flag];
     if(ans!=-1) return ans;
      if(pos>=n)
      {
          if(flag==0) return 1e14;
        else   return 0;
      }

     if(flag)
     {
           int op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
           return ans=op2;
     }
     else
     {
         int op1,op2;
         op1=y+solve(pos+1,0);
        op2=(s[pos]=='0'?x:0)+solve(pos+k,1);
        return ans=min(op1,op2);
     }
}
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int t;
     cin>>t;
     while(t--)
     {
          cin>>n>>p>>k>>s>>x>>y;
          for(int i=0; i<=n+5; i++)
            for(int j=0; j<=2; j++)
            dp[i][j]=-1;
          int ans=solve(p-1,0);
          cout<<ans<<endl;

     }
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll fp(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1)
        res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
        ll n, p, k;
        cin>>n>>p>>k;
        string s;
        cin>>s;
        ll x, y, start=k;
        cin>>x>>y;
        vector<vector<ll>> v(k, vector<ll>(1, 0));
        for(int i=p-1;i<n;i++){
            ll now=(start++ - k)%k;
            v[now].push_back(s[i] == '0' ? x : 0);
            v[now][v[now].size()-1] += v[now][v[now].size()-2];
        }
        ll ans = 1e9;
        // for(auto i: v){
        //     for(auto j: i)  cout<<j<<" ";
        //     cout<<'\n';
        // }
        ll shift=0;
        for(int i=0;i<=n-p;i++){
            // cout<<shift<<" "<<i%k<<'\n';
            // shift/=k;
            ans = min(ans, y*(i) + v[i%k][v[i%k].size()-1] - v[i%k][shift]);
            if((i-p-k+k)%k == 0) ++shift;
            // cout<<ans<<'\n';
        }
        cout<<ans<<'\n';
    }
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll fp(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1)
        res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
        ll n, p, k;
        cin>>n>>p>>k;
        string s;
        cin>>s;
        ll x, y, start=k;
        cin>>x>>y;
        vector<vector<ll>> v(k, vector<ll>(1, 0));
        for(int i=p-1;i<n;i++){
            ll now=(start++ - k)%k;
            v[now].push_back(s[i] == '0' ? x : 0);
            v[now][v[now].size()-1] += v[now][v[now].size()-2];
        }
        ll ans = 1e9;
        // for(auto i: v){
        //     for(auto j: i)  cout<<j<<" ";
        //     cout<<'\n';
        // }
        ll shift=0;
        for(int i=0;i<=n-p;i++){
            // cout<<shift<<" "<<i%k<<'\n';
            // shift/=k;
            ans = min(ans, y*(i) + v[i%k][v[i%k].size()-1] - v[i%k][shift]);
            if((i+1-p-k)%k == 0) ++shift;
            // cout<<ans<<'\n';
        }
        cout<<ans<<'\n';
    }
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll fp(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1)
        res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
        ll n, p, k;
        cin>>n>>p>>k;
        string s;
        cin>>s;
        ll x, y, start=k;
        cin>>x>>y;
        vector<vector<ll>> v(k, vector<ll>(1, 0));
        for(int i=p-1;i<n;i++){
            ll now=(start++ - k)%k;
            v[now].push_back(s[i] == '0' ? x : 0);
            v[now][v[now].size()-1] += v[now][v[now].size()-2];
        }
        ll ans = 1e9;
        // for(auto i: v){
        //     for(auto j: i)  cout<<j<<" ";
        //     cout<<'\n';
        // }
        ll shift=0;
        for(int i=0;i<=n-p;i++){
            if(i>0 and (i-p)%k == 0 and (i-p)/k >= 1) ++shift;
            // cout<<shift<<" "<<i%k<<'\n';
            // shift/=k;
            ans = min(ans, y*(i) + v[i%k][v[i%k].size()-1] - v[i%k][shift]);

            // cout<<ans<<'\n';
        }
        cout<<ans<<'\n';
    }
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll fp(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1)
        res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
        ll n, p, k;
        cin>>n>>p>>k;
        string s;
        cin>>s;
        ll x, y, start=k;
        cin>>x>>y;
        vector<vector<ll>> v(k, vector<ll>(1, 0));
        for(int i=p-1;i<n;i++){
            ll now=(start++ - k)%k;
            v[now].push_back(s[i] == '0' ? x : 0);
            v[now][v[now].size()-1] += v[now][v[now].size()-2];
        }
        ll ans = 1e9;
        // for(auto i: v){
        //     for(auto j: i)  cout<<j<<" ";
        //     cout<<'\n';
        // }
        for(int i=0;i<n-p;i++){
            ll shift=max(0LL, i+1LL-p-k);
            ans = min(ans, y*(i) + v[i%k][v[i%k].size()-1] - v[i%k][shift]);
        }
        cout<<ans<<'\n';
    }
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll fp(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1)
        res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
        ll n, p, k;
        cin>>n>>p>>k;
        string s;
        cin>>s;
        ll x, y, start=k;
        cin>>x>>y;
        vector<vector<ll>> v(k, vector<ll>(1, 0));
        for(int i=p-1;i<n;i++){
            ll now=(start++ - k)%k;
            v[now].push_back(s[i] == '0' ? x : 0);
            v[now][v[now].size()-1] += v[now][v[now].size()-2];
        }
        ll ans = 1e9;
        // for(auto i: v){
        //     for(auto j: i)  cout<<j<<" ";
        //     cout<<'\n';
        // }
        ll shift=0;
        for(int i=0;i<=n-p;i++){
            // cout<<shift<<" "<<i%k<<'\n';
            // shift/=k;
            if(i>0 and (i-p+1)%k == 0) ++shift;
            ans = min(ans, y*(i) + v[i%k][v[i%k].size()-1] - v[i%k][shift]);

            // cout<<ans<<'\n';
        }
        cout<<ans<<'\n';
    }
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll fp(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1)
        res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
        ll n, p, k;
        cin>>n>>p>>k;
        string s;
        cin>>s;
        ll x, y, start=k;
        cin>>x>>y;
        vector<vector<ll>> v(k, vector<ll>(1, 0));
        for(int i=p-1;i<n;i++){
            ll now=(start++ - k)%k;
            v[now].push_back(s[i] == '0' ? x : 0);
            v[now][v[now].size()-1] += v[now][v[now].size()-2];
        }
        ll ans = 1e9;
        // for(auto i: v){
        //     for(auto j: i)  cout<<j<<" ";
        //     cout<<'\n';
        // }
        for(int i=0;i<n-p;i++){
            ll shift=max(0LL, i+1LL-p-k);
            // cout<<shift<<" "<<i%k<<'\n';
            shift%=k;
            ans = min(ans, y*(i) + v[i%k][v[i%k].size()-1] - v[i%k][shift]);
        }
        cout<<ans<<'\n';
    }
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll fp(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1)
        res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
        ll n, p, k;
        cin>>n>>p>>k;
        string s;
        cin>>s;
        ll x, y, start=k;
        cin>>x>>y;
        vector<vector<ll>> v(k, vector<ll>(1, 0));
        for(int i=p-1;i<n;i++){
            ll now=(start++ - k)%k;
            v[now].push_back(s[i] == '0' ? x : 0);
            v[now][v[now].size()-1] += v[now][v[now].size()-2];
        }
        ll ans = 1e9;
        for(auto i: v){
            for(auto j: i)  cout<<j<<" ";
            cout<<'\n';
        }
        for(int i=0;i<n-p;i++){
            ll shift=max(0LL, i+1LL-p-k);
            // cout<<shift<<" "<<i%k<<'\n';
            shift%=k;
            ans = min(ans, y*(i) + v[i%k][v[i%k].size()-1] - v[i%k][shift]);
        }
        cout<<ans<<'\n';
    }
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll fp(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1)
        res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
        ll n, p, k;
        cin>>n>>p>>k;
        string s;
        cin>>s;
        ll x, y, start=k;
        cin>>x>>y;
        vector<vector<ll>> v(k, vector<ll>(1, 0));
        for(int i=p-1;i<n;i++){
            ll now=(start++ - k)%k;
            v[now].push_back(s[i] == '0' ? x : 0);
            v[now][v[now].size()-1] += v[now][v[now].size()-2];
        }
        ll ans = 1e9;
        // for(auto i: v){
        //     for(auto j: i)  cout<<j<<" ";
        //     cout<<'\n';
        // }
        ll shift=0;
        for(int i=0;i<=n-p;i++){
            if((i-k)%k == 0 and (i-k)/k >= 0) ++shift;
            // cout<<shift<<" "<<i%k<<'\n';
            // shift/=k;
            ans = min(ans, y*(i) + v[i%k][v[i%k].size()-1] - v[i%k][shift]);

            // cout<<ans<<'\n';
        }
        cout<<ans<<'\n';
    }
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll fp(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1)
        res*=a;
        a*=a;
        b/=2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
        ll n, p, k;
        cin>>n>>p>>k;
        string s;
        cin>>s;
        ll x, y, start=k;
        cin>>x>>y;
        vector<vector<ll>> v(k, vector<ll>(1, 0));
        for(int i=p-1;i<n;i++){
            ll now=(start++ - k)%k;
            v[now].push_back(s[i] == '0' ? x : 0);
            v[now][v[now].size()-1] += v[now][v[now].size()-2];
        }
        ll ans = 1e9;
        // for(auto i: v){
        //     for(auto j: i)  cout<<j<<" ";
        //     cout<<'\n';
        // }
        ll shift=0;
        for(int i=0;i<=n-p;i++){
            // cout<<shift<<" "<<i%k<<'\n';
            // shift/=k;
            ans = min(ans, y*(i) + v[i%k][v[i%k].size()-1] - v[i%k][shift]);
            if(i>0 and (i-p+1)%k == 0) ++shift;
            // cout<<ans<<'\n';
        }
        cout<<ans<<'\n';
    }
	return 0;
}


#include <bits/stdc++.h>
#define arr(i,n) for(int i=0;i<n;i++)
#define ARR(i,n) for(int i=n-1;i>=0;i--)
#define f(i,a,b)  for(int i=a;i<b;i++)
#define F(i,a,b)  for(int i=b-1;i>=a;i--)
#define float double
#define pb push_back
#define mp make_pair
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n) for(int i=0;i<n;++i) cout<<a[i]<<" "
#define inputarr2D(a,n,m) for(int i=0;i<n;++i) for(int j=0;j<n;++j) cout<<a[i][j]
#define lineend cout<<endl
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;
const int  mod = 1000000000 + 7;
void solve()
{
    //code start here
    ll n,p,k;
    cin>>n>>p>>k;
    ll ar[k]={0};
    string s;
    vector<char>v;
    cin>>s;
    arr(i,n)
    {v.pb(s[i]);
        if(i>=p-1)
        {
            if(s[i]=='0') ar[(i+1-p)%k]++;
        }
    }
    ll x,y;
    cin>>x>>y;
    arr(i,k) ar[i]=ar[i]*x+i*y;
    ll res=ar[0];
    f(i,1,k) res=min(res,ar[i]);
    ll answer=res;
    f(i,p+k-1,n-p+1)
    {
        if(s[i-k]=='0') ar[(i+1-p)%k]-=x;
        ll num=ar[(i+1-p)%k]+y*k;
        res=min(res,num);
    }
    cout<<answer<<endl;
}
int main()
{
    //code start here
    int t;
    cin>>t;
    while(t--)
      solve();
    return 0;
}


#include <bits/stdc++.h>
#define arr(i,n) for(int i=0;i<n;i++)
#define ARR(i,n) for(int i=n-1;i>=0;i--)
#define f(i,a,b)  for(int i=a;i<b;i++)
#define F(i,a,b)  for(int i=b-1;i>=a;i--)
#define float double
#define pb push_back
#define mp make_pair
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n) for(int i=0;i<n;++i) cout<<a[i]<<" "
#define inputarr2D(a,n,m) for(int i=0;i<n;++i) for(int j=0;j<n;++j) cout<<a[i][j]
#define lineend cout<<endl
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;
const int  mod = 1000000000 + 7;
void solve()
{
    //code start here
    ll n,p,k;
    cin>>n>>p>>k;
    string s;
    vector<char>v;
    cin>>s;
    arr(i,n) v.pb(s[i]);
    ll x,y;
    cin>>x>>y;
    ll answer=INT_MAX;
    arr(j,n-p)
    {ll res=0;
    for(ll i=p-1+j;i<n;i=i+k)
        {if(v[i]=='0') res+=x; }
    answer=min(answer,res+y*j);
    }
    cout<<answer<<endl;
}
int main()
{
    //code start here
    int t;
    cin>>t;
    while(t--)
      solve();
    return 0;
}


#include <bits/stdc++.h>
#define arr(i,n) for(int i=0;i<n;i++)
#define ARR(i,n) for(int i=n-1;i>=0;i--)
#define f(i,a,b)  for(int i=a;i<b;i++)
#define F(i,a,b)  for(int i=b-1;i>=a;i--)
#define float double
#define pb push_back
#define mp make_pair
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n) for(int i=0;i<n;++i) cout<<a[i]<<" "
#define inputarr2D(a,n,m) for(int i=0;i<n;++i) for(int j=0;j<n;++j) cout<<a[i][j]
#define lineend cout<<endl
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;
const int  mod = 1000000000 + 7;
void solve()
{
    //code start here
    ll n,p,k;
    cin>>n>>p>>k;
    ll ar[k]={0};
    string s;
    vector<char>v;
    cin>>s;
    arr(i,n)
    {v.pb(s[i]);
        if(i>=p-1)
        {
            if(s[i]=='0') ar[(i+1-p)%k]++;
        }
    }
    ll x,y;
    cin>>x>>y;
    arr(i,k) ar[i]=ar[i]*x+y*i;
    ll res=ar[0];
    f(i,1,k) if(p+i-1<n) res=min(res,ar[i]);
    ll answer=res;
    f(i,p+k-1,n-p+1)
    {
        if(s[i-k]=='0') ar[(i+1-p)%k]-=x;
        ll num=ar[(i+1-p)%k]+y*k;
        res=min(res,num);
        // debug(num);
        ar[(i+1-p)%k]+=y*k;
    }
    cout<<res<<endl;
}
int main()
{
    //code start here
    int t;
    cin>>t;
    while(t--)
      solve();
    return 0;
}


#include <bits/stdc++.h>
#define arr(i,n) for(int i=0;i<n;i++)
#define ARR(i,n) for(int i=n-1;i>=0;i--)
#define f(i,a,b)  for(int i=a;i<b;i++)
#define F(i,a,b)  for(int i=b-1;i>=a;i--)
#define float double
#define pb push_back
#define mp make_pair
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n) for(int i=0;i<n;++i) cout<<a[i]<<" "
#define inputarr2D(a,n,m) for(int i=0;i<n;++i) for(int j=0;j<n;++j) cout<<a[i][j]
#define lineend cout<<endl
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;
const int  mod = 1000000000 + 7;
void solve()
{
    //code start here
    int n, p, k,x,y;
    string s;
    cin>>n>>p>>k>>s>>x>>y;
    int dp[n];
    arr(i,n) dp[i]=0;
    for(int i=n-1;i>=p-1;i--)
    {
        if(s[i]=='0') dp[i]+=x;
        if(i+k<n) dp[i]+=dp[i+k];
    }
    int res=INT_MAX;
    f(i,p-1,n)
    {
        res=min(res,dp[i]+(i-p+1)*y);
    }
    cout<<res<<endl;
}
int main()
{
    //code start here
    int t;
    cin>>t;
    while(t--)
      solve();
    return 0;
}


#include <bits/stdc++.h>
#define arr(i,n) for(int i=0;i<n;i++)
#define ARR(i,n) for(int i=n-1;i>=0;i--)
#define f(i,a,b)  for(int i=a;i<b;i++)
#define F(i,a,b)  for(int i=b-1;i>=a;i--)
#define float double
#define pb push_back
#define mp make_pair
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n) for(int i=0;i<n;++i) cout<<a[i]<<" "
#define inputarr2D(a,n,m) for(int i=0;i<n;++i) for(int j=0;j<n;++j) cout<<a[i][j]
#define lineend cout<<endl
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;
const int  mod = 1000000000 + 7;
void solve()
{
    //code start here
    ll n,p,k;
    cin>>n>>p>>k;
    ll ar[k]={0}; //for first k platform
    string s;
    cin>>s;
    ll x,y;
    cin>>x>>y;
    f(i,p-1,n)
    {
        if(s[i]=='0') ar[(i+1-p)%k]+=x;
    }
    arr(i,k) ar[i]+=i*y;
    // arr(i,k) cout<<ar[i]<<" ";
    // cout<<endl;
    ll res=ar[0];
    arr(i,k) res=min(res,ar[i]);
    f(i,p+k-1,n-p+1)
    {
        if(s[i-k]=='0') ar[(i+1-p)%k]-=x;
        ll num=ar[(i+1-p)%k]+y*k;
        res=min(res,num);
        // debug(num);
    }
    cout<<res<<endl;
}
int main()
{
    //code start here
    int t;
    cin>>t;
    while(t--)
      solve();
    return 0;
}


#include <bits/stdc++.h>
#define arr(i,n) for(int i=0;i<n;i++)
#define ARR(i,n) for(int i=n-1;i>=0;i--)
#define f(i,a,b)  for(int i=a;i<b;i++)
#define F(i,a,b)  for(int i=b-1;i>=a;i--)
#define float double
#define pb push_back
#define mp make_pair
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n) for(int i=0;i<n;++i) cout<<a[i]<<" "
#define inputarr2D(a,n,m) for(int i=0;i<n;++i) for(int j=0;j<n;++j) cout<<a[i][j]
#define lineend cout<<endl
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;
const int  mod = 1000000000 + 7;
void solve()
{
    //code start here
    ll n,p,k;
    cin>>n>>p>>k;
    ll ar[k]={0};
    string s;
    vector<char>v;
    cin>>s;
    arr(i,n)
    {v.pb(s[i]);
        if(i>=p-1)
        {
            if(s[i]=='0') ar[(i+1-p)%k]++;
        }
    }
    ll x,y;
    cin>>x>>y;
    arr(i,k) ar[i]=ar[i]*x+y*i;
    ll res=ar[0];
    f(i,1,k) res=min(res,ar[i]);
    ll answer=res;
    f(i,p+k-1,n-p+1)
    {
        if(s[i-k]=='0') ar[(i+1-p)%k]-=x;
        ll num=ar[(i+1-p)%k]+y*k;
        res=min(res,num);
        // debug(num);
        ar[(i+1-p)%k]+=y*k;
    }
    cout<<res<<endl;
}
int main()
{
    //code start here
    int t;
    cin>>t;
    while(t--)
      solve();
    return 0;
}


#include <bits/stdc++.h>
#define arr(i,n) for(int i=0;i<n;i++)
#define ARR(i,n) for(int i=n-1;i>=0;i--)
#define f(i,a,b)  for(int i=a;i<b;i++)
#define F(i,a,b)  for(int i=b-1;i>=a;i--)
#define float double
#define pb push_back
#define mp make_pair
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n) for(int i=0;i<n;++i) cout<<a[i]<<" "
#define inputarr2D(a,n,m) for(int i=0;i<n;++i) for(int j=0;j<n;++j) cout<<a[i][j]
#define lineend cout<<endl
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;
const int  mod = 1000000000 + 7;
void solve()
{
    //code start here
    ll n,p,k;
    cin>>n>>p>>k;
    ll ar[k]={0};
    string s;
    vector<char>v;
    cin>>s;
    arr(i,n)
    {v.pb(s[i]);
        if(i>=p-1)
        {
            if(s[i]=='0') ar[(i+1-p)%k]++;
        }
    }
    ll x,y;
    cin>>x>>y;
    arr(i,k) ar[i]=ar[i]*x+y*i;
    ll res=ar[0];
    for(ll i=1;i<k&&i+p<n;i++) res=min(res,ar[i]);
    ll answer=res;
    f(i,p+k-1,n-p+1)
    {
        if(s[i-k]=='0') ar[(i+1-p)%k]-=x;
        ll num=ar[(i+1-p)%k]+y*k;
        res=min(res,num);
        // debug(num);
        ar[(i+1-p)%k]+=y*k;
    }
    cout<<res<<endl;
}
int main()
{
    //code start here
    int t;
    cin>>t;
    while(t--)
      solve();
    return 0;
}


#include <bits/stdc++.h>
#define arr(i,n) for(int i=0;i<n;i++)
#define ARR(i,n) for(int i=n-1;i>=0;i--)
#define f(i,a,b)  for(int i=a;i<b;i++)
#define F(i,a,b)  for(int i=b-1;i>=a;i--)
#define float double
#define pb push_back
#define mp make_pair
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n) for(int i=0;i<n;++i) cout<<a[i]<<" "
#define inputarr2D(a,n,m) for(int i=0;i<n;++i) for(int j=0;j<n;++j) cout<<a[i][j]
#define lineend cout<<endl
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;
const int  mod = 1000000000 + 7;
void solve()
{
    //code start here
    int n, p, k,x,y;
    string s;
    cin>>n>>p>>k>>s>>x>>y;
    int dp[n];
    arr(i,n) dp[i]=0;
    ARR(j,n) {
            if (s[j] != '1') {
                dp[j] += x;
            }
            if (j + k <= n - 1) {
                dp[j] += dp[j + k];
            }
        }
    int ans =INT_MAX;
    for (int j = p - 1; j < n; j++) {
            ans = min(dp[j] + (j - p + 1) * y, ans);
        }
        cout<<ans<<endl;
}
int main()
{
    //code start here
    int t;
    cin>>t;
    while(t--)
      solve();
    return 0;
}


#include <bits/stdc++.h>
#define arr(i,n) for(int i=0;i<n;i++)
#define ARR(i,n) for(int i=n-1;i>=0;i--)
#define f(i,a,b)  for(int i=a;i<b;i++)
#define F(i,a,b)  for(int i=b-1;i>=a;i--)
#define float double
#define pb push_back
#define mp make_pair
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n) for(int i=0;i<n;++i) cout<<a[i]<<" "
#define inputarr2D(a,n,m) for(int i=0;i<n;++i) for(int j=0;j<n;++j) cout<<a[i][j]
#define lineend cout<<endl
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;
const int  mod = 1000000000 + 7;
void solve()
{
    //code start here
    ll n,p,k;
    cin>>n>>p>>k;
    ll ar[k]={0};
    string s;
    vector<char>v;
    cin>>s;
    arr(i,n)
    {v.pb(s[i]);
        if(i>=p-1)
        {
            if(s[i]=='0') ar[(i+1-p)%k]++;
        }
    }
    ll x,y;
    cin>>x>>y;
    arr(i,k) ar[i]=ar[i]*x+i*y;
    ll res=ar[0];
    f(i,1,k) res=min(res,ar[i]);
    ll answer=res;
    f(i,p+k-1,n-p+1)
    {
        if(s[i-k]=='0') ar[(i+1-p)%k]-=x;
        ll num=ar[(i+1-p)%k]+y;
        res=min(res,num);
    }
    cout<<answer<<endl;
}
int main()
{
    //code start here
    int t;
    cin>>t;
    while(t--)
      solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll int
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()

#define MAX 100005

string s;
ll n, p, k, x, y;
ll dp[MAX][2];

ll solve(ll pos, ll go)
{
	if(pos>=n)
	{
		if(go) return 1e9;
		return 0;
	}

	ll &ret = dp[pos][go];

	if(ret!=-1) return ret;

	ll w = s[pos]-'0';

	ll res = 1e9;

	if(n-pos >= p and go)
		res = (y*pos) + solve(pos+p-1,0);

	if(!go) res = min(res, ((!w)*x) + solve(pos+k,go));

	res= min(res, solve(pos+1, 1));

	return ret = res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	ll t;
	cin >> t;

	while(t--)
	{
		cin >> n >> p >> k;
		cin >> s;
		cin >> x >> y;

		for(int i=0;i<=n;i++)
			dp[i][0] = dp[i][1] = -1;

		cout << solve(0,1) << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()

#define MAX 100005

string s;
ll n, p, k, x, y;
ll dp[MAX][2];

ll solve(ll pos, ll go)
{
	if(pos>=n)
	{
		if(go) return 1e9;
		return 0;
	}

	ll &ret = dp[pos][go];

	if(ret!=-1) return ret;

	ll w = s[pos]-'0';

	ll res = 1e9;

	if(n-pos >= p)
		res = (y*pos) + solve(pos+p-1,0);

	if(!go) res = min(res, ((!w)*x) + solve(pos+k,go));

	res= min(res, solve(pos+1, 1));

	return ret = res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	ll t;
	cin >> t;

	while(t--)
	{
		cin >> n >> p >> k;
		cin >> s;
		cin >> x >> y;

		for(int i=0;i<=n;i++)
			dp[i][0] = dp[i][1] = -1;

		cout << solve(0,1) << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()

#define MAX 500005

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	ll t;
	cin >> t;

	while(t--)
	{
		ll n, p, k, x, y;
		cin >> n >> p >> k;

		string s;
		cin >> s;

		cin >> x >> y;

		ll ans = 1e18;
		for(int i=0;i<k;i++)
		{
			ll cans= y*i;

			if(n - i < p) break;

			ll c=0;
			for(int j=i+p-1;j<n;j+=k)
			{
				c+=k;
				ll w = s[j]-'0';
				if(w == 1) continue;
				cans+= x;
			}

			ans = min(ans,cans);
		}

		cout << ans << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()

#define MAX 500005

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	ll t;
	cin >> t;

	while(t--)
	{
		ll n, p, k, x, y;
		cin >> n >> p >> k;

		string s;
		cin >> s;

		cin >> x >> y;

		ll cum[n+5];

		vector<ll> in[2];

		for(int i=0;i<n;i++)
			in[s[i]-'0'].push_back(i);

		ll ans = 1e18;
		for(int i=0;i<k;i++)
		{
			ll cans= y*i;
			for(int j=i+p-1;j<n;j+=k)
			{
				ll w = s[j]-'0';
				if(w == 1) continue;
				cans+= x;
			}

			ans = min(ans,cans);
		}

		cout << ans << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()

#define MAX 500005

string s;
ll n, p, k, x, y;
ll dp[MAX][2];

ll solve(ll pos, ll go)
{
	if(pos>=n)
	{
		if(go) return 1e9;
		return 0;
	}

	ll &ret = dp[pos][go];

	if(ret!=-1) return ret;

	ll w = s[pos]-'0';

	ll res = 1e9;

	if(n-pos >= p)
		res = (y*pos) + solve(pos+p-1,0);

	if(!go) res = min(res, ((!w)*x) + solve(pos+k,go));

	res= min(res, solve(pos+1, 1));

	return ret = res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	ll t;
	cin >> t;

	while(t--)
	{
		cin >> n >> p >> k;
		cin >> s;
		cin >> x >> y;

		for(int i=0;i<=n;i++)
			dp[i][0] = dp[i][1] = -1;

		cout << solve(0,1) << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll int
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()

#define MAX 100005

string s;
ll n, p, k, x, y;
ll dp[MAX][2];

ll solve(ll pos, ll go)
{
	if(pos>=n)
	{
		if(go) return 1e9;
		return 0;
	}

	ll &ret = dp[pos][go];

	if(ret!=-1) return ret;

	ll w = s[pos]-'0';

	ll res = 1e9;

	if(n-pos >= p)
		res = (y*pos) + solve(pos+p-1,0);

	if(!go) res = min(res, ((!w)*x) + solve(pos+k,go));

	res= min(res, solve(pos+1, 1));

	return ret = res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	ll t;
	cin >> t;

	while(t--)
	{
		cin >> n >> p >> k;
		cin >> s;
		cin >> x >> y;

		for(int i=0;i<=n;i++)
			dp[i][0] = dp[i][1] = -1;

		cout << solve(0,1) << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()

#define MAX 500005

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	ll t;
	cin >> t;

	while(t--)
	{
		ll n, p, k, x, y;
		cin >> n >> p >> k;

		string s;
		cin >> s;

		cin >> x >> y;

		ll ans = 1e18;
		for(int i=0;i<k;i++)
		{
			ll cans= y*i;

			if(n - i <= p) break;

			ll c=0;
			for(int j=i+p-1;j<n;j+=k)
			{
				c+=k;
				ll w = s[j]-'0';
				if(w == 1) continue;
				cans+= x;
			}

			ans = min(ans,cans);
		}

		cout << ans << endl;
	}

	return 0;
}


#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <ios>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second

ll mod = 1e9 + 7;
ll add(ll a, ll b)
{
    ll res = a + b;
    while (res >= mod)
    {
        res -= mod;
    }
    while (res < 0)
    {
        res += mod;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    int tt;
    cin >> tt;
    while (tt--)
    {
        int n, p, k;
        cin >> n >> p >> k;
        int arr[n + 1];
        for (int i = 1; i <= n; i++)
        {
            char a;
            cin >> a;
            arr[i] = a - '0';
        }
        ll x, y;
        cin >> x >> y;
        ll sm = 0;
        ll ans = 1e18;
        vector<ll> v(n + 1, 0);
        for (int i = p; i <= n; i++)
        {
            if (i < p + k)
            {
                if (arr[i] == 1)
                {
                    v[i] = 1;
                }
            }
            else
            {
                if (arr[i] == 1)
                {
                    v[i] = v[i - k] + 1;
                }
                else
                {
                    v[i] = v[i - k];
                }
            }
            // cout << v[i] << ' ';
        }
        for (int i = n - k; i >= p; i--)
        {
            v[i] = v[i + k];
        }
        // for (int i = 1; i <= n; i++)
        // {
        //     // cout << v[i] << ' ';
        // }
        // // cout << '\n';
        for (int i = p; i <= n; i++)
        {
            ll need = (n - i) / k + 1;
            // cout << i << ' ' << need << ' ' << v[i] << ' ' << sm << '\n';
            ans = min(ans, sm + (need - v[i]) * x);
            sm += y;
        }
        cout << min(sm, ans) << '\n';
    }
    return 0;
}


#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <ios>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second

ll mod = 1e9 + 7;
ll add(ll a, ll b)
{
    ll res = a + b;
    while (res >= mod)
    {
        res -= mod;
    }
    while (res < 0)
    {
        res += mod;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    int tt;
    cin >> tt;
    while (tt--)
    {
        int n, p, k;
        cin >> n >> p >> k;
        int arr[n + 1];
        for (int i = 1; i <= n; i++)
        {
            char a;
            cin >> a;
            arr[i] = a - '0';
        }
        ll x, y;
        cin >> x >> y;
        vector<int> res(n + 1, 0);
        ll mx = INT_MIN;
        int d;
        int have = 0;
        for (int i = p; i <= n; i++)
        {
            if (i < p + k)
            {
                if (arr[i] == 1)
                {
                    res[i] = 1;
                }
            }
            else
            {
                if (arr[i] == 1)
                {
                    res[i] = res[i - k] + 1;
                    if (res[i] > mx)
                    {
                        mx = res[i];
                        d = (i - p) % k;
                    }
                }
            }
            if ((i - p) % k == 0)
            {
                if (arr[i] == 1)
                {
                    have++;
                }
            }
        }
        // cout << mx << ' ' << d << '\n';
        int need = ((n - p + 1) + k - 1) / k;
        int need2 = ((n - p + 1 - d) + k - 1) / k;
        cout << min((need - have) * x, d * y + (need2 - mx) * x) << '\n';
    }
    return 0;
}


#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <ios>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second

ll mod = 1e9 + 7;
ll add(ll a, ll b)
{
    ll res = a + b;
    while (res >= mod)
    {
        res -= mod;
    }
    while (res < 0)
    {
        res += mod;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    int tt;
    cin >> tt;
    while (tt--)
    {
        int n, p, k;
        cin >> n >> p >> k;
        int arr[n + 1];
        for (int i = 1; i <= n; i++)
        {
            char a;
            cin >> a;
            arr[i] = a - '0';
        }
        ll x, y;
        cin >> x >> y;
        ll sm = 0;
        ll ans = 1e18;
        vector<ll> v(n + 1, 0);
        for (int i = n; i >= p; i--)
        {
            if (arr[i] == 1)
            {
                if (i + k <= n)
                {
                    v[i] = v[i + k] + 1;
                }
                else
                {
                    v[i] = 1;
                }
            }
            else
            {
                if (i + k <= n)
                {
                    v[i] = v[i + k];
                }
            }
        }
        // for (int i = 1; i <= n; i++)
        // {
        //     cout <<
        // }
        for (int i = p; i <= n; i++)
        {
            ll need = (n - i) / k + 1;
            // cout << i << ' ' << need << ' ' << v[i] << ' ' << sm << '\n';
            ans = min(ans, sm + (need - v[i]) * x);
            sm += y;
        }
        cout << min(sm, ans) << '\n';
    }
    return 0;
}


#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <ios>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second

ll mod = 1e9 + 7;
ll add(ll a, ll b)
{
    ll res = a + b;
    while (res >= mod)
    {
        res -= mod;
    }
    while (res < 0)
    {
        res += mod;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    int tt;
    cin >> tt;
    while (tt--)
    {
        int n, p, k;
        cin >> n >> p >> k;
        int arr[n + 1];
        for (int i = 1; i <= n; i++)
        {
            char a;
            cin >> a;
            arr[i] = a - '0';
        }
        int x, y;
        cin >> x >> y;
        vector<int> res(n + 1, 0);
        int mx = INT_MIN;
        int d;
        int have = 0;
        for (int i = p; i <= n; i++)
        {
            if (i < p + k)
            {
                if (arr[i] == 1)
                {
                    res[i] = 1;
                }
            }
            else
            {
                if (arr[i] == 1)
                {
                    res[i] = res[i - k] + 1;
                    if (res[i] > mx)
                    {
                        mx = res[i];
                        d = (i - p) % k;
                    }
                }
            }
            if ((i - p) % k == 0)
            {
                if (arr[i] == 1)
                {
                    have++;
                }
            }
        }
        // cout << mx << ' ' << d << '\n';
        int need = ((n - p + 1) + k - 1) / k;
        int need2 = ((n - p + 1 - d) + k - 1) / k;
        cout << min((need - have) * x, d * y + (need2 - mx) * x) << '\n';
    }
    return 0;
}


#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <ios>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second

ll mod = 1e9 + 7;
ll add(ll a, ll b)
{
    ll res = a + b;
    while (res >= mod)
    {
        res -= mod;
    }
    while (res < 0)
    {
        res += mod;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    int tt;
    cin >> tt;
    while (tt--)
    {
        int n, p, k;
        cin >> n >> p >> k;
        int arr[n + 1];
        for (int i = 1; i <= n; i++)
        {
            char a;
            cin >> a;
            arr[i] = a - '0';
        }
        ll x, y;
        cin >> x >> y;
        ll sm = 0;
        ll ans = 1e18;
        vector<ll> v(n + 1, 0);
        for (int i = n; i >= p; i--)
        {
            if (arr[i] == 1)
            {
                if (i + k <= n)
                {
                    v[i] = v[i + k] + 1;
                }
                else
                {
                    v[i] = 1;
                }
            }
            else
            {
                if (i + k <= n)
                {
                    v[i] = v[i + k];
                }
            }
        }
        int c = 0;
        for (int i = p; i <= n; i++)
        {
            ll need = (n - i) / k + 1;
            ans = min(ans, sm + (need - v[i]) * x);
            sm += y;
            c++;
            if (c > n - p)
            {
                break;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


#include <iostream>
#include <ostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <ios>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second

ll mod = 1e9 + 7;
ll add(ll a, ll b)
{
    ll res = a + b;
    while (res >= mod)
    {
        res -= mod;
    }
    while (res < 0)
    {
        res += mod;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    int tt;
    cin >> tt;
    while (tt--)
    {
        int n, p, k;
        cin >> n >> p >> k;
        int arr[n + 1];
        for (int i = 1; i <= n; i++)
        {
            char a;
            cin >> a;
            arr[i] = a - '0';
        }
        ll x, y;
        cin >> x >> y;
        ll sm = 0;
        ll ans = 1e18;
        vector<ll> v(n + 1, 0);
        for (int i = p; i <= n; i++)
        {
            if (i < p + k)
            {
                if (arr[i] == 1)
                {
                    v[i] = 1;
                }
            }
            else
            {
                if (arr[i] == 1)
                {
                    v[i] = v[i - k] + 1;
                }
                else
                {
                    v[i] = v[i - k];
                }
            }
            // cout << v[i] << ' ';
        }
        for (int i = n - k; i >= p; i--)
        {
            v[i] = v[i + k];
        }
        for (int i = 1; i <= n; i++)
        {
            // cout << v[i] << ' ';
        }
        // cout << '\n';
        for (int i = p; i <= n; i++)
        {
            ll need = (n - i) / k + 1;
            // cout << i << ' ' << need << ' ' << v[i] << ' ' << sm << '\n';
            ans = min(ans, sm + (need - v[i]) * x);
            sm += y;
        }
        cout << ans << '\n';
    }
    return 0;
}


//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);
const int MOD = 1e9+7; // 998244353;
const int MXS = 2e5+5;
const int MXI = 1e9+5;
const ll MXL = 1e18+5;

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}

void task()
{
	// Code here...

	int t, n, p, k, x, y;
	string s;

	cin >> t;
	while(t--){
		cin >> n >> p >> k >> s >> x >> y;

		int now = p, ans = 0;
		while(now<=n){
			if(s[now-1]=='0'){
				int cnt = 0, K;
				for(K=now-1; K<n; K++){
					if(s[K]=='1') break;
					cnt++;
				}

				if(y*cnt<=x){
					now = K+1;
					ans += y*cnt;
				}
				else{
					now = now+k;
					ans += x;
				}
				continue;
			}

			now = now+k;
		}

		cout << ans << "\n";
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	task();

    return 0;
}


//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);
const int MOD = 1e9+7; // 998244353;
const int MXS = 2e5+5;
const int MXI = 1e9+5;
const ll MXL = 1e18+5;

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}

ll t, n, p, k, x, y, dp[100005];
string s;
ll calc(ll now)
{
	if(dp[now]!=-1) return dp[now];

	int ans = 0;

	for(int K=now; K<=n; K+=k){
		if(s[K-1]=='0') ans += x;
	}

	return dp[now] = ans;
}
void task()
{
	// Code here...

	cin >> t;
	while(t--){
		cin >> n >> p >> k >> s >> x >> y;

		ll ans = MXI;
		memset(dp, -1, sizeof dp);
		for(int K=n; K>=p; K--){
			ans = min(ans, calc(K)+(K-p)*y);
		}

		cout << ans << "\n";
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	task();

    return 0;
}


//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);
const int MOD = 1e9+7; // 998244353;
const int MXS = 2e5+5;
const int MXI = 1e9+5;
const ll MXL = 1e18+5;

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}

ll t, n, p, k, x, y, dp[100005];
string s;
void task()
{
	// Code here...

	cin >> t;
	while(t--){
		cin >> n >> p >> k >> s >> x >> y;

		ll ans = MXI;

		int ara[n+k+5];
		memset(ara, 0, sizeof ara);
		for(int K=n-1; K>=0; K--){
			if(s[K]=='0') ara[K] = ara[K+k]+1;
			else ara[K] = ara[K+k];
		}

		for(int K=n; K>=p; K--){
			ans = min(ans, ara[K-1]*x+(K-p)*y);
		}

		cout << ans << "\n";
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	task();

    return 0;
}


//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);
const int MOD = 1e9+7; // 998244353;
const int MXS = 2e5+5;
const int MXI = 1e9+5;
const ll MXL = 1e18+5;

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}

ll t, n, p, k, x, y, dp[100005];
string s;
void task()
{
	// Code here...

	cin >> t;
	while(t--){
		cin >> n >> p >> k >> s >> x >> y;

		ll ans = MXI;

		int ara[n+5];
		memset(ara, 0, sizeof ara);
		for(int K=n-1; K>=0; K--){
			if(s[K]=='0') ara[K] = ara[K+k]+1;
			else ara[K] = ara[K+k];
		}

		for(int K=n; K>=p; K--){
			ans = min(ans, ara[K-1]*x+(K-p)*y);
		}

		cout << ans << "\n";
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	task();

    return 0;
}


//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);
const int MOD = 1e9+7; // 998244353;
const int MXS = 2e5+5;
const int MXI = 1e9+5;
const ll MXL = 1e18+5;

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

// chess moves...
// int dx[] = {+0, +0, -1, +1}; ///Up-down, Left-Right
// int dy[] = {+1, -1, +0, +0};
// int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
// int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1};
// int dx[] = {-2, -2, -1, -1,  1,  1,  2,  2}; ///Knight's Move
// int dy[] = {-1,  1, -2,  2, -2,  2, -1,  1};

// structs...
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};

// functions...
ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}

ll t, n, p, k, x, y, dp[100005];
string s;
ll calc(ll now)
{
	int ans = 0;

	for(int K=now; K<=n; K+=k){
		if(s[K-1]=='0') ans += x;
	}

	return ans;
}
void task()
{
	// Code here...

	cin >> t;
	while(t--){
		cin >> n >> p >> k >> s >> x >> y;

		ll ans = MXI;
		for(int K=p; K<=n; K++){
			ans = min(ans, calc(K)+(K-p)*y);
		}

		cout << ans << "\n";
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	task();

    return 0;
}


//Created By:Hardik Kapoor
#include<bits/stdc++.h>

using namespace std;
//template begins
#define int long long int
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itt vector<int>:: iterator
#define pb push_back
#define mp make_pair
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define min3(a,b,c) min(min((a),(b)),(c))
#define min4(a,b,c,d) min(min((a),(b)),min((c),(d)))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define db long double
#define itp vector<pair<int,int> >:: iterator
#define ff first
#define ss second
#define endl "\n"
typedef pair<int,int> pii;
const int inf=1000000000000000000;
const long double pi = 3.14159265358979323846264338;
const long long mod = 1000000007;
// const long long mod = 998244353;

int pow(int x, unsigned int y, int p){
    int res=1;
    x=x%p;
    if (x==0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int invmod(int a,int m){
	return pow(a,m-2,m);
}
//template ends
const int maxn=1e5+5;
vector<int> adj[maxn],par(maxn),si(maxn);
set<int> ma;

void make_set(int a)
{
	ma.insert(a);
	par[a]=a;
	si[a]=1;
}

int find_set(int a)
{
	if(par[a]==a)
		return a;
	return par[a]=find_set(par[a]);
}

void union_set(int a,int b)
{
	a=find_set(a);
	b=find_set(b);
	if(a!=b)
	{
		if(si[a]<si[b])
			swap(a,b);
		par[b]=a;
		si[a]+=si[b];
		ma.erase(b);
	}
}

signed main(){
	ios
	int n,m;
	cin>>n>>m;
	for(int i=0,x,y;i<m;i++)
	{
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	for(int i=1;i<=n;i++)
	{
		make_set(i);
		map<int,int> mm;
		for(int x:adj[i])
		{
			if(x<i)
				mm[find_set(x)]++;
		}
		for(int y:ma)
		{
			if(mm.find(y)==mm.end())
				union_set(y,i);
			else if(mm[y]<si[y])
			{
				union_set(y,i);
			}
		}
	}
	cout<<ma.size()-1<<endl;
}