#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k, g;
  string s;
  cin >> n >> k >> s >> g;
  s += s;
  unordered_map<string, long long> mys;
  set<long long> used;
  for (long long i = 0; i < g; ++i) {
    string s1;
    cin >> s1;
    mys.insert(make_pair(s1, i + 1));
  }
  long long ans[n];
  bool done;
  for (long long j = (n - 1) * k; j < n * k; ++j) {
    done = true;
    for (long long i = 0; i < n; ++i) {
      auto it = mys.find(s.substr(j + i * k, k));
      if (it == mys.end() || used.count(it->second)) {
        done = false;
        break;
      }
      ans[i] = it->second;
      used.insert(it->second);
    }
    if (done) break;
    used.clear();
  }
  if (!done)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (long long i = 0; i < n; ++i) cout << ans[i] << " ";
  }
  return 0;
}
