#include <bits/stdc++.h>
using namespace std;
const long long sze = 1 << 21, MOD1 = 1e9 + 447, MOD2 = 1e9 + 21, x1 = 139;
int n, k, g, m;
inline long long MOD11(long long v) {
  if (v < 0) {
    if (-v < MOD1)
      return v + MOD1;
    else
      return v % MOD1 + MOD1;
  }
  if (v < MOD1)
    return v;
  else
    return v % MOD1;
}
long long power[sze] = {1}, cnt[sze];
map<pair<long long, long long>, int> cnt_mp;
map<pair<long long, long long>, int> positions;
pair<long long, long long> get_substr(int l, int r,
                                      const vector<long long> &v) {
  if (!l)
    return make_pair(v[r], cnt[r]);
  else
    return make_pair(MOD11(v[r] - v[l - 1] * power[r - l + 1]),
                     cnt[r] - cnt[l - 1]);
}
pair<long long, long long> all_hash(const string &s) {
  int n = s.size();
  long long cnt = s[0];
  long long cnt2 = s[0];
  for (int i = 1; i < n; ++i) {
    cnt = MOD11(cnt * x1 + s[i]);
    cnt2 += s[i];
  }
  return make_pair(cnt, cnt2);
}
void get_solution(int start, const vector<long long> &v) {
  cout << "YES\n";
  int ind = start;
  for (int i = 0; i < n; ++i) {
    pair<long long, long long> h = get_substr(ind, ind + k - 1, v);
    cout << positions[h] + 1 << ' ';
    ind += k;
  }
}
int main() {
  for (int i = 1; i < sze; ++i) power[i] = MOD11(power[i - 1] * x1);
  string s;
  cin >> n >> k >> s;
  m = s.size();
  vector<long long> my_hash(2 * m);
  my_hash[0] = s[0];
  cnt[0] = s[0];
  s += s;
  for (int i = 1; i < 2 * m; ++i) {
    my_hash[i] = MOD11(my_hash[i - 1] * x1 + s[i]);
    cnt[i] += cnt[i - 1] + s[i];
  }
  vector<string> challengers;
  cin >> g;
  for (int i = 0; i < g; ++i) {
    string s;
    cin >> s;
    challengers.push_back(s);
    pair<long long, long long> v = all_hash(s);
    if (cnt_mp.count(v))
      cnt_mp[v]++;
    else
      cnt_mp[v] = 1;
    positions[v] = i;
  }
  int g_start = -1;
  for (int start = 0; start < k; ++start) {
    map<pair<long long, long long>, int> cur_cnt;
    for (auto v : cnt_mp) cur_cnt[v.first] = v.second;
    int ind = start;
    bool label = 1;
    for (int i = 0; i < n; ++i) {
      pair<long long, long long> hsh = get_substr(ind, ind + k - 1, my_hash);
      if (cur_cnt.count(hsh) && cur_cnt[hsh])
        cur_cnt[hsh]--;
      else
        label = 0;
      ind += k;
    }
    if (label) {
      g_start = start;
      break;
    }
  }
  if (g_start != -1)
    get_solution(g_start, my_hash);
  else
    cout << "NO";
  return 0;
}
