#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 9;
const long long MOD1 = (long long)1e9 + 17;
const long long alp = 26;
const long long p = rand() % (MOD - alp) + alp + 1;
const long long p1 = rand() % (MOD1 - alp) + alp + 1;
const int MAX_NK = (int)1e6;
long long h[2 * MAX_NK];
long long h1[2 * MAX_NK];
pair<long long, long long> cnt_hash(string &s) {
  long long res = 0;
  long long res1 = 0;
  for (int i = 0; i < (int)s.size(); i++) {
    res = ((res * p) % MOD + s[i] - 'a' + 1) % MOD;
    res1 = ((res1 * p1) % MOD1 + s[i] - 'a' + 1) % MOD1;
  }
  return {res, res1};
}
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  cin >> s;
  s = s + s;
  long long curr = 0, curr1 = 0;
  long long mod = 1, mod1 = 1;
  for (int i = 0; i < k; i++) {
    curr = ((curr * p) % MOD + s[i] - 'a' + 1) % MOD;
    curr1 = ((curr1 * p1) % MOD1 + s[i] - 'a' + 1) % MOD1;
    mod = (mod * p) % MOD;
    mod1 = (mod1 * p1) % MOD1;
  }
  h[0] = curr;
  h1[0] = curr1;
  for (int i = 1; i < 2 * n * k; i++) {
    curr = ((curr * p) % MOD + s[(i + k - 1) % (2 * n * k)] - 'a' + 1) % MOD;
    curr1 =
        ((curr1 * p1) % MOD1 + s[(i + k - 1) % (2 * n * k)] - 'a' + 1) % MOD1;
    curr = ((curr - (s[i - 1] - 'a' + 1) * mod) % MOD + MOD) % MOD;
    curr1 = ((curr1 - (s[i - 1] - 'a' + 1) * mod1) % MOD1 + MOD1) % MOD1;
    h[i] = curr;
    h1[i] = curr1;
  }
  int g;
  cin >> g;
  string s1;
  set<pair<long long, long long> > hashes;
  map<pair<long long, long long>, int> mh;
  for (int i = 0; i < g; i++) {
    cin >> s1;
    pair<long long, long long> hsh = cnt_hash(s1);
    hashes.insert(hsh);
    mh[hsh] = i + 1;
  }
  set<pair<long long, long long> > _h1;
  vector<pair<long long, long long> > h2;
  for (int i = 0; i < k; i++) {
    _h1.clear();
    h2.clear();
    for (int j = 0; i + j * k < n * k; j++) {
      if (hashes.find({h[i + j * k], h1[i + j * k]}) != hashes.end()) {
        _h1.insert({h[i + j * k], h1[i + j * k]});
        h2.push_back({h[i + j * k], h1[i + j * k]});
      }
    }
    if (_h1.size() == n) {
      cout << "YES\n";
      for (int j = 0; j < (int)h2.size(); j++) {
        cout << mh[h2[j]] << " ";
      }
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
