#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

short str[300001];
vector<short> words[600002];
int prices[600002];

unsigned long long dyn[300001];

int main()
{
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    int m, n, l;
    cin >> m >> n >> l;
    for (int i = 0; i < m; i++)
    {
        char s;
        cin >> s;
        str[i] = s - '0';
    }
    for (int i = 0; i < n; i++)
    {
        cin >> prices[i];
        string q;
        cin >> q;
        for (int s = 0; s < q.size(); s++)
        {
            words[2 * i].push_back(q[s] - '0');
            words[2 * i + 1].push_back(q[q.size() - 1 - s] - '0');
        }
    }
    for (int pos = 0; pos < m; pos++)
    {
        dyn[pos] = -1;
    }
    for (int pos = 0; pos < m; pos++)
    {
        for (int word = 0; word < n; word++)
        {
            int len = 0;
            while (pos >= len && (words[2 * word + 1][len] == str[pos - len]))
            {
                if (pos == len)
                {
                    dyn[pos] = min(dyn[pos], (unsigned long long)prices[word]);
                }
                else
                {
                    dyn[pos] = min(dyn[pos], dyn[pos - len - 1] + prices[word]);
                }
                len++;
            }
        }
        for (int word = 0; word < n; word++)
        {
            int len = 0;
            while (pos + len + 1 < m && (words[2 * word][len] == str[pos + len + 1]))
            {
                dyn[pos + len + 1] = min(dyn[pos + len + 1], dyn[pos] + prices[word]);
                len++;
            }
        }
    }
    if (dyn[m - 1] == -1ULL)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << dyn[m - 1] << endl;
    }
    return 0;
}
