#include <bits/stdc++.h>
using namespace std;
const long long M = (1LL << 31) - 1;
const long long base = 347;
const int N = 2e6 + 7;
long long power(long long a, long long p) {
  if (p == 0) return 1;
  long long ans = power(a, p / 2);
  ans = (ans * ans) % M;
  if (p % 2) ans = (ans * a) % M;
  return ans;
}
long long inverse(long long a) { return power(a, M - 2); }
long long pb[N];
long long invb;
void hashPre() {
  pb[0] = 1;
  for (int i = 1; i < N; i++) pb[i] = (pb[i - 1] * base) % M;
  invb = inverse(pb[1]);
}
long long Hash(string s) {
  long long ans = 0;
  for (int i = 0; i < s.size(); i++) ans = (ans * base + s[i]) % M;
  return ans;
}
vector<long long> hashList(string s) {
  int n = s.size();
  vector<long long> ans(n + 1);
  ans[0] = 0;
  for (int i = 1; i <= n; i++) ans[i] = (ans[i - 1] * base + s[i - 1]) % M;
  return ans;
}
long long substringHash(const vector<long long> &hashlist, int l, int r) {
  int len = (r - l + 1);
  return ((hashlist[r] - hashlist[l - 1] * pb[len]) % M + M) % M;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  hashPre();
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<long long> hl = hashList(s + s);
  map<long long, int> mp;
  int g;
  cin >> g;
  for (int i = 1; i <= g; i++) {
    string s;
    cin >> s;
    mp[Hash(s)] = i;
  }
  for (int i = 0; i < k; i++) {
    set<int> ans;
    vector<int> out;
    for (int j = i; j < n * k; j += k) {
      long long h = substringHash(hl, j + 1, j + k);
      if (mp.count(h) == 0) break;
      ans.insert(mp[h]);
      out.push_back(mp[h]);
    }
    if (ans.size() != n) continue;
    cout << "YES" << endl;
    for (int x : out) cout << x << " ";
    return 0;
  }
  cout << "NO" << endl;
}
