#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <array>
#include <algorithm>

typedef long long ll;
using namespace std;

#define INF 1791791791791791ll

struct trie
{
    vector<array<int, 2> > vec;
    vector<ll> native_cnt;
    array<int, 2> _default;
    vector<int> h;
    void add_string(const string& s, ll cnt)
    {
        int v = 0;
        for (char c : s)
        {
            c -= '0';
            if (vec[v][c] == -1)
            {
                vec[v][c] = vec.size();
                vec.push_back(_default);
                native_cnt.push_back(INF);
            }
            native_cnt[v] = min(native_cnt[v], cnt);
            v = vec[v][c];
        }
        native_cnt[v] = min(native_cnt[v], cnt);
    }
    trie()
    {
        _default = {-1, -1};
        vec = {_default};
        native_cnt = {INF};
    }
};

int main()
{
#ifndef LOCAL
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
#endif
    int m, n, L;
    cin >> m >> n >> L;
    string s;
    cin >> s;
    trie ahc;
    int lmx = 0;
    vector<string> vc;
    vector<ll> cc;
    for (int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        string t;
        cin >> t;
        ahc.add_string(t, c);
        vc.push_back(t);
        cc.push_back(c);
        reverse(t.begin(), t.end());
        vc.push_back(t);
        cc.push_back(c);
        ahc.add_string(t, c);
        lmx = max(lmx, (int)t.size());
    }
    vector<ll> dp(m + 1, 0);
    for (int i = 0; i < m; i++)
    {
        dp[i + 1] = INF;
        for (int k = 0; k < 2 * n; k++)
        {
            for (int j = i; j >= 0 && i - j < (int)vc[k].size(); j--)
            {
                if (s[j] != vc[k][i - j])
                    break;
                dp[i + 1] = min(dp[i + 1], dp[j] + cc[k]);
            }
        }
    }
    if (dp[m] == INF)
        cout << -1 << endl;
    else
        cout << dp[m] << endl;
    return 0;
}
