#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define sqr(x) (x) * (x)

const ll INF = 1e15, LEN = 5500;

struct Node
{
    ll  num;
    Node *ar[2];

    Node()
    {
        ar[0] = ar[1] = NULL;
        num = INF;
    }
};

void push(Node *v, string &st, ll c)
{
    for (int i = 0; i < st.length(); i++)
    {
        if (v->ar[st[i] - '0'] == NULL)
            v->ar[st[i] - '0'] = new Node();
        v = v->ar[st[i] - '0'];
        v->num = min(v->num, c);
    }
}


void push1(Node *v, int l, string &st, ll c)
{
    for (int i = l; i < st.length(); i++)
    {
        if (v->ar[st[i] - '0'] == NULL)
            v->ar[st[i] - '0'] = new Node();
        v = v->ar[st[i] - '0'];
    }

    v->num = min(v->num, c);
}


int m, n;
ll dp[LEN], c, l;
string st, st1;

Node *root, *v;

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


    cin >> m >> n >> l;
    cin >> st;

    root = new Node();

    for (int i = 0; i < n; i++)
    {
        cin >> c;
        cin >> st1;

        push(root, st1, c);

        for (int j = 1; j < st1.length(); j++)
            push1(root, j, st1, c);

    }

    st = '`' + st;

    dp[0] = 0;
    for (int i = 1; i <= m; i++)
        dp[i] = INF;


    for (int i = 0; i < m; i++)
    {
        v = root;
        for (int j = i + 1; j <= m; j++)
        {
            if (v->ar[st[j] - '0'] == NULL)
                break;
            v = v->ar[st[j] - '0'];
            dp[j] = min(dp[j], dp[i] + v->num);
        }

    }

    if (dp[m] == INF)
        cout << -1;
    else
        cout << dp[m];

    return 0;
}
/*
9 2 8
000110100
1 100
1 11001
*/
