#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 9;
const int inf = (int)2e9;
const long long INF = (long long)1e18;
const int base = 1000 * 1000 * 1000;
const int maxn = 105;
const long double pi = acosl(-1.0);
const long double eps = 1e-9;
char buff[1000005];
void solve() {
  int n, k, q, p1 = 31, p2 = 26;
  scanf("%d %d", &n, &k);
  scanf(" %s", buff);
  string s(buff);
  assert((int)s.size() == 1LL * n * k);
  s += s.substr(0, k);
  map<pair<long long, long long>, int> mapa;
  vector<long long> pw1(k + 1, 1);
  vector<long long> pw2(k + 1, 1);
  for (int i = 1; i < k + 1; i++) pw1[i] = pw1[i - 1] * p1;
  for (int i = 1; i < k + 1; i++) pw2[i] = pw2[i - 1] * p2;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    long long hash1 = 0, hash2 = 0;
    scanf(" %s", buff);
    string t(buff);
    assert((int)t.size() == k);
    for (int j = 0; j < (int)t.size(); j++) {
      hash1 = hash1 + t[j] * pw1[j];
      hash2 = hash2 + t[j] * pw2[j];
    }
    mapa[make_pair(hash1, hash2)] = i + 1;
  }
  assert(q == (int)mapa.size());
  vector<int> dp((int)s.size(), -1);
  vector<set<int>> a(k);
  long long hash1 = 0, hash2 = 0;
  for (int i = (int)s.size() - k; i < (int)s.size(); i++) {
    hash1 = hash1 + s[i] * pw1[i - (int)s.size() + k];
    hash2 = hash2 + s[i] * pw2[i - (int)s.size() + k];
  }
  for (int i = (int)s.size() - 1; i >= (int)s.size() - k; i--) dp[i] = 0;
  for (int i = (int)s.size() - k - 1; i >= 0; i--) {
    hash1 = hash1 * p1 - s[i + k] * pw1[k] + s[i];
    hash2 = hash2 * p2 - s[i + k] * pw2[k] + s[i];
    map<pair<long long, long long>, int>::iterator it =
        mapa.find(make_pair(hash1, hash2));
    if (it != mapa.end()) {
      int c = (*it).second;
      int d = i % k;
      if (dp[i + k] != -1 && a[d].find(c) == a[d].end()) {
        dp[i] = c;
        a[d].insert(c);
      }
    }
  }
  for (int i = 0; i < k; i++)
    if (dp[i] != -1) {
      puts("YES");
      int j = i;
      while (dp[j] != 0) {
        printf("%d ", dp[j]);
        j += k;
      }
      return;
    }
  puts("NO");
}
int main() {
  solve();
  return 0;
}
