#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <unordered_map>
#include <algorithm>

using namespace std;

int n, m, l, n0;
long long dp[1000000];
int trie[8000000][2];
int cost[8000000];
string s;

int main()
{
    ios_base::sync_with_stdio(false);
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> m >> n >> l;
    cin >> s;
    m = s.length();
    n0 = 2;
    for (int i1 = 1; i1 <= n; i1++)
    {
        string s1;
        int cs;
        cin >> cs >> s1;

        int v = 1;
        for (int i = 0; i < s1.length(); i++)
        {
            int c = int(s1[i] - '0');
            if (trie[v][c] == 0)
            {
                trie[v][c] = n0;
                v = n0;

                if (cost[v] == 0)
                {
                    cost[v] = cs;
                } else
                {
                    cost[v] = min(cost[v], cs);
                }

                n0++;
            } else
            {
                v = trie[v][c];

                if (cost[v] == 0)
                {
                    cost[v] = cs;
                } else
                {
                    cost[v] = min(cost[v], cs);
                }
            }
        }


        for (int l1 = 1; l1 < s1.length(); l1++)
        {
            v = 1;
            for (int i = l1; i < s1.length(); i++)
            {
                int c = int(s1[i] - '0');
                if (trie[v][c] == 0)
                {
                    trie[v][c] = n0;
                    v = n0;
                    n0++;
                } else
                {
                    v = trie[v][c];
                }
            }

            if (cost[v] == 0)
            {
                cost[v] = cs;
            } else
            {
                cost[v] = min(cost[v], cs);
            }
        }
    }

    for (int i = 0; i < s.length(); i++)
    {
        dp[i] = 1e18;

        for (int g = i; g >= 0; g--)
        {
            bool bad = false;
            int v = 1;
            for (int j = g; j <= i; j++)
            {
                int c = int(s[j] - '0');
                if (trie[v][c] == 0)
                {
                    bad = true;
                    break;
                }

                v = trie[v][c];
            }

            if (!bad && cost[v] > 0)
            {
                if (g == 0)
                {
                    dp[i] = min(dp[i], (long long) cost[v]);
                } else
                {
                    dp[i] = min(dp[i], dp[g - 1] + cost[v]);
                }
            }
        }
    }

    if (dp[m - 1] >= 1e18)
    {
        cout << -1 << endl;
    } else
    {
        cout << dp[m - 1] << endl;
    }

    return 0;
}
