#include <bits/stdc++.h>

#define vec vector
#define pb push_back
#define all(a) a.begin(), a.end()
#define re return
#define str string
#define ll long long
#define XX first
#define YY second
#define forn(i, n) for (int i = 0; i < n; i++)

using namespace std;

const long long p = 997;
const long long MOD = 1e9 + 7;
const long long LINF = 1e18 + 7;

ll l, n;
map <ll, ll> cost;
pair<ll, str> a[300007];
ll osn[300007];
ll h[300007];
str s;
ll dp[300007];

ll get(str s)
{
    h[0] = 0;
    osn[0] = 1;
    forn(i, s.size())
    {
        h[i + 1] = ((ll)s[i] * (ll)osn[i] % MOD + (ll)h[i]) % MOD;
        osn[i + 1] = osn[i] * p % MOD;
    }
    re h[s.size()];
}

void did(str s, ll cos)
{
    h[0] = 0;
    osn[0] = 1;
    forn(i, s.size())
    {
        h[i + 1] = ((ll)(s[i]) * (ll)osn[i] % MOD + (ll)h[i]) % MOD;
        osn[i + 1] = osn[i] * p % MOD;
    }
    forn(i, s.size())
    {
        if (cost.count(h[i]))
            cost[h[i]] = min(cost[h[i]], cos);
        else
            cost[h[i]] = cos;
    }
    str s1 = "";
    for (int i = (int)s.size() - 1; i >= 0; i--)
    {
        s1 = s[i] + s1;
        ll ha = get(s1);
        if (cost.count(ha))
            cost[ha] = min(cost[ha], cos);
        else
            cost[ha] = cos;
    }
}

ll get1(char c)
{
    if (c == '1')
        re 49;
    else
        re 48;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie();
    freopen("typing.in", "r", stdin);
    freopen("typing.out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    ll et;
    cin >> l >> n >> et >> s;
    forn(i, n)
        cin >> a[i].XX >> a[i].YY;
    forn(i, n)
        did(a[i].YY, a[i].XX);
    //for (map <ll, ll> :: iterator it = cost.begin(); it != cost.end(); it++)
    //    cout << it -> first << ' ' << it -> second << endl;

    if (cost.count(get1(s[0])))
        dp[0] = cost[get1( s[0] )];
    else
        dp[0] = LINF;
    for (int i = 1; i < l; i++)
    {
        str s1 = "";
        s1 += s[i];
        dp[i] = LINF;
        if (dp[i - 1] != LINF && cost.count(get1(s1[0])))
            dp[i] = dp[i - 1] + cost[get1(s1[0])];
        for (int j = i - 1; j >= 0; j--)
        {
            s1 = s[j] + s1;
            if (j == 0)
            {
                if (dp[i - 1] != LINF && cost.count(get(s1)))
                    dp[i] = min(dp[i], cost[get(s1)]);
            }
            else
            {
                if (dp[i - 1] != LINF && cost.count(get(s1)))
                    dp[i] = min(dp[i], dp[j - 1] + cost[get(s1)]);
            }
        }
    }
    //forn(i, l)
    //    cout << dp[i] << ' ';
    if (dp[l - 1] == LINF)
        cout << -1;
    else
        cout << dp[l - 1];
}
