#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <array>
#include <algorithm>

typedef long long ll;
using namespace std;

#define INF 1791791791791791ll

struct aho_corasick
{
    vector<array<int, 2> > vec;
    vector<ll> native_cnt;
    array<int, 2> _default;
    vector<int> h;
    void add_string(const string& s, ll cnt)
    {
        int v = 0;
        for (char c : s)
        {
            c -= '0';
            if (vec[v][c] == -1)
            {
                vec[v][c] = vec.size();
                vec.push_back(_default);
                native_cnt.push_back(INF);
            }
            v = vec[v][c];
        }
        native_cnt[v] = min(native_cnt[v], cnt);
    }
    void dfs(int v, int hg)
    {
        h[v] = hg;
        for (int u : vec[v])
        {
            if (u != -1)
            {
                dfs(u, hg + 1);
                native_cnt[v] = min(native_cnt[v], native_cnt[u]);
            }
        }
    }
    void run_dfs()
    {
        h.resize(vec.size());
        dfs(0, 0);
    }
    vector<int> suflink;
    void bfs()
    {
        suflink.resize(vec.size());
        suflink[0] = -1;
        queue<int> q;
        q.push(0);
        while (!q.empty())
        {
            int a = q.front();
            q.pop();
            if (h[a] == 0)
            {
                for (int u : vec[a])
                {
                    if (u != -1)
                    {
                        q.push(u);
                        suflink[u] = 0;
                    }
                }
            }
            else
            {
                for (int i = 0; i < 2; i++)
                {
                    if (vec[a][i] != -1)
                    {
                        int x = suflink[a];
                        while (x >= 0 && vec[x][i] == -1)
                            x = suflink[x];
                        if (x == -1)
                            suflink[vec[a][i]] = -1;
                        else
                            suflink[vec[a][i]] = vec[x][i];
                        q.push(vec[a][i]);
                    }
                }
            }   
        }
    }
    int go(int u, char c)
    {
        c -= '0';
        while (u != -1 && vec[u][c] == -1)
            u = suflink[u];
        if (u == -1)
            return 0;
        else
            return vec[u][c];
    }
    aho_corasick()
    {
        _default = {-1, -1};
        vec = {_default};
        native_cnt = {INF};
    }
};

int main()
{
#ifndef LOCAL
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
#endif
    int m, n, L;
    cin >> m >> n >> L;
    string s;
    cin >> s;
    aho_corasick ahc;
    for (int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        string t;
        cin >> t;
        ahc.add_string(t, c);
        reverse(t.begin(), t.end());
        ahc.add_string(t, c);
    }
    ahc.run_dfs();
    ahc.bfs();
    int v = 0;
    vector<ll> dp(m + 1, 0);
    for (int i = 0; i < m; i++)
    {
        v = ahc.go(v, s[i]);
        dp[i + 1] = INF;
        int u = v;
        while (u != -1)
        {
            dp[i + 1] = min(dp[i + 1], dp[i + 1 - ahc.h[u]] + ahc.native_cnt[u]);   
            u = ahc.suflink[u];
        }
    }
    if (dp[m] == INF)
        cout << -1 << endl;
    else
        cout << dp[m] << endl;
    return 0;
}
