#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;

const long long BIG_NUMBER = 1000000000000000;

struct begining
{
    string pref;
    long long prev;
    long long coord, num;
};

int main()
{
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);


    long long n, m, L, i, j;
    cin >> m >> n >> L;
    string nabor;
    cin >> nabor;
    vector < pair <long long, string> > keypad;
    long long a;
    string b;
    for(i = 0; i < n; i++)
    {
        cin >> a >> b;
        keypad.push_back({a, b});
        reverse(b.begin(), b.end());
        keypad.push_back({a, b});
    }

    /*if(m > 11)
        cout << 1 / 0;
    if(m > 10)
        cout << "Azaza";
    if(m > 9)
        while(true)
            n *= 1;*/

    /*for(i = 0; i < n; i++)
    {
        string pref, suff;
        pref = suff = "";
        for(j = 0; j < keypad[i].size(); j++)
        {
            pref.push_back(keypad[i][j]);
            suff.push_back(keypad[i][keypad[i].size() - j - 1]);
            begins.push_back({pref, costs[i]});
            begins.push_back({suff, costs[i]});
        }
    }*/

    //go go go
    long long dp[m];
    vector <begining> dp_var[m];
    dp[0] = BIG_NUMBER;
    for(i = 0; i < keypad.size(); i++)
    {
        if(keypad[i].second[0] == nabor[0])
        {
            begining tmp;
            tmp.pref = keypad[i].second;
            tmp.prev = -1;
            tmp.num = i;
            tmp.coord = 0;
            dp_var[0].push_back(tmp);
            if(keypad[i].first < dp[0])
                dp[0] = keypad[i].first;
        }
    }

    //cout << "here";

    // code itself
    for(i = 1; i < m; i++)
    {
        //cout << "started";
        for(j = 0; j < dp_var[i - 1].size(); j++)
        {
            if(dp_var[i - 1][j].coord < dp_var[i - 1][j].pref.size() - 1 and nabor[i] == dp_var[i - 1][j].pref[dp_var[i - 1][j].coord + 1])
            {
                dp_var[i].push_back(dp_var[i - 1][j]);
                dp_var[i][dp_var[i].size() - 1].coord++;
            }
        }
        //cout << "gotta";
        for(j = 0; j < keypad.size(); j++)
        {
            if(keypad[j].second[0] == nabor[i])
            {
                begining tmp;
                tmp.pref = keypad[j].second;
                tmp.prev = i - 1;
                tmp.num = j;
                tmp.coord = 0;
                dp_var[i].push_back(tmp);
            }
        }
        //cout << "new begins found";
        //counting dp
        dp[i] = BIG_NUMBER;
        for(j = 0; j < dp_var[i].size(); j++)
        {
            long long now_cost = keypad[dp_var[i][j].num].first;
            long long prev_cost = (dp_var[i][j].prev == -1) ? 0 : dp[dp_var[i][j].prev];
            if(now_cost + prev_cost < dp[i])
                dp[i] = now_cost + prev_cost;
        }

        //kostyl
        if(dp[i] == BIG_NUMBER)
        {
            cout << -1;
            return 0;
        }
    }

    //answer
    if(dp[m - 1] >= BIG_NUMBER)
        cout << -1;
    else
        cout << dp[m - 1];
    return 0;
}
