#include<bits/stdc++.h>

using namespace std;

typedef long long lint;

const lint inf = 1e18;

#define X first
#define Y second
#define F(i, l, r) for(auto i = l; i != r; i++)
#define Df(i, l, r) for(auto i = l; i != r; i--)
#define rs resize
#define asg assign
#define mk make_pair
#define ins insert
#define era erase
#define all(x) x.begin(),x.end()
#define ret return
#define cont continue
#define brk break


struct node{
    vector<node*> nxt;
    lint val;
    bool fin;
    node(){fin = false; nxt.rs(2); nxt.asg(2, NULL); val = inf;}
};


const string fname = "typing";

node * proot, *sroot;

void trie_add(node * root, string & s, lint nv){
    node * v = root;
    int n = s.length();
    root->val = min(root->val, nv);
    F(i, 0, n){
        int c = s[i] - '0';
        if(v->nxt[c] == NULL)
            v->nxt[c] = new node();
        v = v->nxt[c];
        v->val = min(v->val, nv);
    }
    v->fin = true;
}

int n, m, L;
string s;
vector<string> t, rt;
vector<int> c;
vector<lint> dp;
string rvs;

int main(){
    string fin = fname + ".in";
    string fout = fname + ".out";
    freopen(fin.c_str(), "r", stdin);
    freopen(fout.c_str(), "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    proot = new node; sroot = new node;
    cin >> m >> n >> L;
    t.rs(n); c.rs(n); rt.rs(n);
    cin >> s;
    rvs = s;
    reverse(rvs.begin(), rvs.end());
    F(i, 0, n){
        cin >> c[i];
        cin.get();
        cin >> t[i];
        rt[i] = t[i];
        reverse(rt[i].begin(), rt[i].end());
        trie_add(proot, t[i], c[i]);
        //trie_add(sroot, rt[i], c[i]);
        F(j, 0, (int)t[i].length()){
            string tmp = t[i].substr(j);
            trie_add(sroot, tmp, c[i]);
        }
    }
    dp.rs(m + 1);
    dp.asg(m + 1, inf);
    dp[0] = 0ll;
    F(i, 0, m){
        node * pv = proot;
        F(j, i + 1, m + 1){
            int c = s[j - 1] - '0';
            if(pv->nxt[c] == NULL)
                brk;
            pv = pv->nxt[c];
            dp[j] = min(dp[j], dp[i] + pv->val);
        }
        node * sv = sroot;
        F(j, i + 1, m + 1){
            int c = s[j - 1] - '0';
            if(sv->nxt[c] == NULL)
                brk;
            sv = sv->nxt[c];
            if(sv->fin)
                dp[j] = min(dp[j], dp[i] + sv->val);
        }
    }
    if(dp[m] == inf)
        printf("-1");
    else
        printf("%lld", dp[m]);
    ret 0;
}
