#include <bits/stdc++.h>

#define mp make_pair
#define pb bush_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 5e5 + 7;
const int M = 5e3 + 7;
const ll INF = 1e9 + 7;

struct str{
    str * to[2];
    ll c;
    str(){
        to[0] = to[1] = NULL;
        c = 0;
    }
};

str b[N];
string s, k[N];
int sz = 1;
ll c[N], d[N];

void add(int e, ll x){
    str * root = b;
    for (int i = 0; i < k[e].size(); i++){
        if (root->to[k[e][i] - '0'] == NULL){
            root->to[k[e][i] - '0'] = b + sz++;
            root->to[k[e][i] - '0']->to[0] = root->to[k[e][i] - '0']->to[1] = NULL;
            root->to[k[e][i] - '0']->c = INF;
        }
        root = root->to[k[e][i] - '0'];
        root->c = min(root->c, x);
    }
}

int init(int n, int m){
    int v = 0;
    for (int i = 0; i < n; i++){
        cin >> c[v] >> k[v];
        v++;
        k[v] = k[v - 1];
        reverse(k[v].begin(), k[v].end());
        c[v] = c[v - 1];
        v++;
    }
    for (int i = 0; i < v; i++)
        add(i, c[i]);
    return v;
}

int main()
{
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, l;
    cin >> m >> n >> l;
    cin >> s;
    b[0].to[0] = b[0].to[1] = NULL;
    init(n, m);
    for (int i = 1; i <= m; i++)
        d[i] = INF * INF;
    for (int i = 0; i < m; i++){
        if (d[i] == INF * INF)
            continue;
        str * root = b;
        for (int j = i; j < m; j++){
            if (root->to[s[j] - '0'] == NULL)
                break;
            root = root->to[s[j] - '0'];
            d[j + 1] = min(d[j + 1], d[i] + root->c);
        }
    }
    //for (int i = 0; i <= m; i++)
    //    cout << d[i] << " ";
    if (d[m] == INF * INF)
        return cout << -1, 0;
    cout << d[m];
    return 0;
}
