#include <iostream>
#include <iomanip>
#include <cstdio>

#include <cassert>
#include <cmath>
#include <algorithm>
#include <utility>

#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <bitset>

using std::cin;
using std::cout;
using std::cerr;

using std::max;
using std::min;
using std::abs;

using std::vector;
using std::set;
using std::map;
using std::string;
using std::pair;
using std::bitset;

#define ff first 
#define ss second
#define pb push_back
#define print(x) cerr << (x) << '\n'
#define dbg(a) cerr << #a << " = " << (a) << '\n'
#define dbg2(a, b) cerr << #a << " = " << (a) << " " << #b << " = " << (b) << '\n'
#define dbg3(a, b, c) cerr << #a << " = " << (a) << " " << #b << " = " << (b) << " " << #c << " = " << (c) << '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void init() {
	#ifndef LOCAL
	freopen("typing.in", "r", stdin);
	freopen("typing.out", "w", stdout);
	#endif
	std::iostream::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(10);
	cerr << std::fixed << std::setprecision(10);
}

const int MAXN = 3e5 + 5, 
		MM = 3;
		// MM = 1;
const ll MOD[MM] = {1000000000 + 7, 1000000000 + 9, 1000000000 + 21}, BASE[MM] = {29, 31, 37};
// const ll MOD[MM] = {1000000000 + 7}, BASE[MM] = {29};
ll pw[MM][MAXN];
ll hs[MM][MAXN];

vector<ll> ht[MM][MAXN];
ll cost[MAXN];
vector<ll> pref[MM][MAXN], suf[MM][MAXN];
// ll sub[MM][MAXN][MAXN];
ll sub(int i, int j, int num) {
	return (hs[num][j] - hs[num][i - 1] + MOD[num]) % MOD[num];
}

ll get_t(int numt, int i, int j, int num) {
	return (ht[num][numt][j] - ht[num][numt][i - 1] + MOD[num]) % MOD[num];
}

void solve1(int n, int m, string & s) {
    vector<pair<string, ll> > kek;
    for (int i = 0; i < n; ++i) {
        int c;
        string t;
        cin >> c >> t;
        int sn = t.length(); 
        {
            string cur = "";
            for (int j = 0; j < sn; ++j) {
                cur += t[j];
                kek.pb({cur, c});
            }
        }
        {
            string cur = "";
            for (int j = sn - 1; j >= 0; --j) {
                cur = t[j] + cur;
                kek.pb({cur, c});
            }
        }
    }
 
    vector<ll> dp(m + 1, 1e18);
    dp[0] = 0;
    s = "#" + s;
    vector<vector<string>> kek2(m + 1, vector<string>(m + 1));
    for (int i = 1; i <= m; ++i) {
        string cur = "";
        for (int j = i; j <= m; ++j) {
            cur += s[j];
            kek2[i][j] = cur;
        }
    }
    for (int i = 1; i <= m; ++i) {
        for (auto j : kek) {
            string t = j.ff;
            ll kek3 = j.ss;
            int sn = t.length();
            if (sn > i)
                continue;
            if (t == kek2[i - sn + 1][i])
                dp[i] = min(dp[i], dp[i - sn] + kek3);
        }
    }
    if (dp[m] == 1e18) dp[m] = -1;
    cout << dp[m] << '\n';
 	return;
}

int main() {
	init();

	int m, n, L;
	string s;
	cin >> m >> n >> L >> s;

	if (L <= 500) {
		solve1(n, m, s);
		return 0;
	}

	pw[0][0] = pw[0][1] = pw[0][2] = 1;
	for (int i = 1; i <= m; ++i)
		for (int j = 0; j < MM; ++j)
			pw[j][i] = (pw[j][i - 1] * BASE[j]) % MOD[j];

	for (int i = 0; i < n; ++i) {
		string t;
		cin >> cost[i] >> t;
		
		int sn = t.length(); 
		
		t = "#" + t;

		for (int j = 0; j < MM; ++j) {
			ht[j][i].assign(sn + 1, 0);
			pref[j][i].resize(sn + 1);
			suf[j][i].resize(sn + 1);
			for (int q = 1; q <= sn; ++q)
			{
				ht[j][i][q] = (ht[j][i][q - 1] + (pw[j][q] * ll(t[q] - '0' + 1)) % MOD[j]) % MOD[j];
			}
			for (int q = 1; q <= sn; ++q) {
				pref[j][i][q] = get_t(i, 1, q, j);
				suf[j][i][sn - q + 1] = get_t(i, q, sn, j);
			}
		}
	}


	vector<ll> dp(m + 1, 1e18);
	dp[0] = 0;
	
	s = "#" + s;
	
	hs[0][0] = hs[0][1] = hs[0][2] = 0;

	for (int i = 1; i <= m; ++i)
		for (int j = 0; j < MM; ++j) {
			hs[j][i] = (hs[j][i - 1] + (pw[j][i] * ll(s[i] - '0' + 1)) % MOD[j]) % MOD[j];
		}
	

	// for (int num = 0; num < MM; ++num)
	// 	for (int i = 1; i <= m; ++i)
	// 		for (int j = i; j <= m; ++j)
	// 			sub[num][i][j] = get_s(i, j, num);


	for (int i = 1; i <= m; ++i) {
		for (int j = 0; j < n; ++j) {
			int e = min(int(pref[0][j].size()), i + 1);
			for (int k = 1; k < e; ++k) {
				bool ok = true;
				for (int num = 0; num < MM; ++num)
					if ((pref[num][j][k] * pw[num][i - k]) % MOD[num] != sub(i - k + 1, i, num)) {
						ok = false;
						break;
					}
				if (ok) {
					dp[i] = min(dp[i], dp[i - k] + cost[j]);
				}
			}
			for (int k = 1; k < e; ++k) {
				bool ok = true;
				if (suf[0][j].size() <= i + 1) {
					for (int num = 0; num < MM; ++num)
						if ((suf[num][j][k] * pw[num][i - suf[0][j].size() + 1]) % MOD[num] != sub(i - k + 1, i, num)) {
							ok = false;
							break;
						}
				} else {
					for (int num = 0; num < MM; ++num)
						if ((sub(i - k + 1, i, num) * pw[num][suf[0][j].size() - i - 1]) % MOD[num] != suf[num][j][k]) {
							ok = false;
							break;
						}
				}
				if (ok) {
					dp[i] = min(dp[i], dp[i - k] + cost[j]);
				}
			}
		}
	}

	if (dp[m] == 1e18) dp[m] = -1;
	cout << dp[m] << '\n';

	return 0;
}