#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

long long mini(long long a, long long b) {
    if (a<b) return a;
    return b;
}

int main () {
    freopen("typing.in","r",stdin);
    freopen("typing.out","w",stdout);
    int m,n,l;
    string s;
    cin>>l>>n>>m>>s;
    vector<long long> dp(s.size(),1000000000000000000ll);
    vector<pair<long long,string> > v(n);
    for (int i=0;i<n;i++) {
        cin>>v[i].first>>v[i].second;
    }
    for (int i=0;i<l;i++) {
       // if (i>0) dp[i] = dp[i-1];
        for (int j=0;j<n;j++) {
            for (int k=0;k+i<l && k<v[j].second.size() ;k++) {
                if (v[j].second[k] != s[i+k])
                    break;
                dp[i+k] = mini(dp[i+k],(i>0?dp[i-1]:0)+v[j].first);

            }
            for (int k=1;k<=v[j].second.size();k++) {
                string kek = v[j].second.substr(v[j].second.size()-k,k);
                if (kek == s.substr(i,k))
                    dp[i+k-1] = mini(dp[i+k-1],(i>0?dp[i-1]:0)+v[j].first);
                //else
                 //   break;
                //cout<<kek<<endl;
            }
        }
      //  for (int ii=0;ii<dp.size();ii++) cout<<dp[ii]<<" ";
        cout<<endl;
        if (dp[i] == 1000000000000000000ll) {
            cout<<-1;
            return 0;
        }
    }
    //for (int i=0;i<dp.size();i++) cout<<dp[i]<<" ";
   cout<<endl<<dp.back();
    return 0;

}
