#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::string;
using std::pair;
using std::make_pair;

using std::min;
using std::max;
using std::abs;

template <typename T>
T input() {
    T res;
    cin >> res;
    return res;
}

struct trie {
    uint32_t min_c = UINT32_MAX;
    trie* go[2] = {nullptr, nullptr};
};

const uint32_t ALLOC = (500 * 1000 * 1000) / sizeof(trie);
trie TRIE[ALLOC];
uint32_t PTR = 0;

trie* new_trie() {
    assert(PTR != ALLOC);
    trie* res = &TRIE[PTR];
    ++PTR;

    return res;
}

void insert(trie* root, const string& str, uint32_t c) {
    root->min_c = min(root->min_c, c);

    for (uint32_t i = 0; i != str.size(); ++i) {
        if (root->go[str[i] - '0'] == nullptr)
            root->go[str[i] - '0'] = new_trie();
        root = root->go[str[i] - '0'];
        root->min_c = min(root->min_c, c);
    }
}

int main() {
#ifndef LOCAL
#define TASK "typing"
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
#endif
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    trie* root_fwd = new_trie();

    input<uint32_t>();
    vector<pair<uint32_t, string>> dat(input<uint32_t>());
    input<uint32_t>();

    string all = input<string>();
    for (auto& v: dat)
        cin >> v.first >> v.second;

    for (const auto& v: dat)
        insert(root_fwd, v.second, v.first);

    trie* root_bck = new_trie();
    for (auto& v: dat) {
        std::reverse(v.second.begin(), v.second.end());
        insert(root_bck, v.second, v.first);
    }

    vector<uint64_t> dp(all.size() + 1, UINT64_MAX);
    dp[0] = 0;
    for (uint32_t i = 0; i <= all.size(); ++i) {
        if (i != 0) {
            // relaxate back.
            trie* cur = root_bck;
            uint32_t delt = 0;
            while (cur != nullptr) {
                if (delt != 0 and cur->min_c != UINT32_MAX)
                    dp[i] = min(dp[i], dp[i - delt] + cur->min_c);

                if (i == delt)
                    break;
                cur = cur->go[all[i - delt - 1] - '0'];
                delt += 1;
            }
        }

        //relaxate forward;
        trie* cur = root_fwd;
        uint32_t delt = 0;
        while (cur != nullptr) {
            if (delt != 0 and cur->min_c != UINT32_MAX)
                dp[i + delt] = min(dp[i + delt], dp[i] + cur->min_c);

            if (i + delt == all.size())
                break;
            cur = cur->go[all[i + delt] - '0'];
            delt += 1;
        }
    }

    if (dp.back() == UINT64_MAX)
        cout << "-1\n";
    else
        cout << dp.back() << "\n";


    return 0;
}