#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2000050;
const long long base = 131;
const long long base2 = 13331;
const long long mod = 19260817;
const long long mod2 = 1e9 + 7;
map<pair<long long, long long>, int> mp;
map<pair<long long, long long>, bool> ape;
long long h[MaxN], bit[MaxN];
long long h2[MaxN], bit2[MaxN], hsh, hsh2;
char str[MaxN], st[MaxN];
int N, K, G, L;
bool ok;
int ans[MaxN], cnt;
pair<long long, long long> query(int L, int R) {
  return make_pair(
      ((h[R] - (h[L - 1] * bit[R - L + 1]) % mod) % mod + mod) % mod,
      ((h2[R] - (h2[L - 1] * bit2[R - L + 1]) % mod2) % mod2 + mod2) % mod2);
}
int main() {
  scanf("%d%d", &N, &K);
  scanf("%s", str + 1);
  bit[0] = bit2[0] = 1;
  L = (N + 2) * K;
  for (int i = N * K + 1; i <= L; ++i) str[i] = str[i - N * K];
  for (int i = 1; i <= L; ++i) bit[i] = (bit[i - 1] * base) % mod;
  for (int i = 1; i <= L; ++i)
    h[i] = (h[i - 1] * base + (str[i] - 'a' + 1)) % mod;
  for (int i = 1; i <= L; ++i) bit2[i] = (bit2[i - 1] * base2) % mod2;
  for (int i = 1; i <= L; ++i)
    h2[i] = (h2[i - 1] * base2 + (str[i] - 'a' + 1)) % mod2;
  scanf("%d", &G);
  for (int i = 1; i <= G; ++i) {
    scanf("%s", st + 1);
    hsh = 0;
    for (int j = 1; j <= K; ++j) hsh = (hsh * base + (st[j] - 'a' + 1)) % mod;
    hsh2 = 0;
    for (int j = 1; j <= K; ++j)
      hsh2 = (hsh2 * base2 + (st[j] - 'a' + 1)) % mod2;
    mp[make_pair(hsh, hsh2)] = i;
  }
  for (int i = 1; i <= K; ++i) {
    ape.clear();
    ok = true;
    cnt = 1;
    for (int j = i; cnt <= N; j += K) {
      if (ape[query(j, j + K - 1)] || !mp.count(query(j, j + K - 1))) {
        ok = false;
        break;
      } else {
        ape[query(j, j + K - 1)] = true;
        ans[cnt++] = mp[query(j, j + K - 1)];
      }
    }
    if (ok) {
      puts("YES");
      for (int i = 1; i <= cnt - 1; ++i) printf("%d ", ans[i]);
      return 0;
    }
  }
  puts("NO");
  return 0;
}
