#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
unordered_map<string, int> mp;
int n, l, m;
string s, u;
int main() {
  cin >> n >> l >> s >> m;
  s += s;
  for (int i = 1; i <= m; i++) {
    cin >> u;
    mp[u] = i;
  }
  int L = n * l;
  bool ok;
  vector<int> ans(n, 0);
  for (int ind = L - l; ind < L; ind++) {
    ok = 1;
    vector<bool> mk(m + 1, 0);
    for (int i = 0; i < n && ok; i++) {
      auto it = mp.find(s.substr(ind + i * l, l));
      if (it == mp.end() || mk[it->second]) {
        ok = 0;
        break;
      }
      mk[it->second] = 1;
      ans[i] = it->second;
    }
    if (ok) break;
  }
  if (!ok)
    printf("NO\n");
  else {
    printf("YES\n");
    for (auto j : ans) printf("%d ", j);
  }
  return 0;
}
