#include <bits/stdc++.h>
using namespace std;
struct Hash {
  __int128_t mod = 1000000000000000003, base = 163;
  vector<__int128_t> p, h;
  int len;
  Hash() {}
  Hash(string str) : len(str.size()) {
    p = vector<__int128_t>(len + 1, 1);
    h = vector<__int128_t>(len + 1, 0);
    for (int i = 1; i <= len; i++) {
      p[i] = p[i - 1] * base % mod;
      h[i] = (h[i - 1] * base + (__int128_t)str[i - 1]) % mod;
    }
  }
  __int128_t substr(int l, int r) {
    return (h[r] - (h[l - 1] * p[r - l + 1]) % mod + mod) % mod;
  }
};
map<long long, int> mp;
map<pair<int, int>, int> x;
const int N = 1e5 + 7;
int ans[N];
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  string str;
  cin >> n >> k >> str;
  str += str.substr(0, k - 1);
  Hash h(str);
  int g;
  cin >> g;
  for (int i = 1; i <= g; i++) {
    string s;
    cin >> s;
    mp[Hash(s).substr(1, k)] = i;
  }
  fill(ans, ans + k, 1);
  for (int i = 0; i + k - 1 < str.size(); i++) {
    if (!mp.count(h.substr(i + 1, i + k))) {
      ans[i % k] = 0;
      continue;
    }
    int j = i % k, ii = mp[h.substr(i + 1, i + k)];
    if (x.count(make_pair(j, ii))) ans[i % k] = 0;
    x[make_pair(j, ii)] = 1;
  }
  int idx = max_element(ans, ans + k) - ans;
  if (!ans[idx]) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
    for (int i = idx; i + k - 1 < str.size(); i += k) {
      cout << mp[h.substr(i + 1, i + k)] << " ";
    }
  }
}
