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

#define xx first
#define yy second
typedef long long ll;
typedef pair<int, int> pii;

int a[1002][1002], b[1002][1002];

map<string, ll> c;
ll dp[(int)1e5+9];
int main()
{
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    int n, m, len;
    cin >> m >> n >> len;
    string s;
    cin >> s;
    for(int i = 0; i < n; i++)
    {
        string str;
        int cost;
        cin >> cost >> str;
        string p = "";
        p += str[0];
        if(c.count(p))
        {
            int z = c[p];
            c[p] = min(z, cost);
        }
        else
            c[p] = cost;
        for(int i = 1; i < str.size(); i++)
        {
            p += str[i];
            if(c.count(p))
            {
                int z = c[p];
                c[p] = min(z, cost);
            }
            else
                c[p] = cost;
        }
        p = "";
        p += str[str.size()-1];
        for(int i = str.size() - 2; i >= 0; i--)
        {
            p = str[i] + p;
            if(c.count(p))
            {
                int z = c[p];
                c[p] = min(z, cost);
            }
            else
                c[p] = cost;
        }
    }
    string q = "" + s[0];
   // cout << c["0"] << "    ASF ASF \n\n";

    dp[0] = c[q];
    for(int i = 1; i < m; i++)
    {
        string tek = "" + s[i];
        ll mn;
        if(c.count(tek))
            mn = dp[i-1] + c[tek];
        else
            mn = (ll)1e15;
        for(int j = i-1; j >= 0; j--)
        {
            tek = s[j] + tek;
            if(c.count(tek))
            {
                if(j > 0)
                    mn = min(mn, dp[j-1] + c[tek]);
                else
                    mn = min(mn, c[tek]);
            }
        }
    }
    if(dp[m-1] >= 1e15)
        cout << -1;
    else
        cout << dp[m-1];
    return 0;
}
