#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long double PI = 3.14159265;
long long int powerWithMod(long long int base, long long int exponent,
                           long long int modulus = LLONG_MAX) {
  long long int result = 1;
  base %= modulus;
  while (exponent > 0) {
    if (exponent % 2 == 1) result = (result * base) % modulus;
    exponent >>= 1;
    base = (base * base) % modulus;
  }
  return result;
}
long long int modInverse(long long int a, long long int m = MOD) {
  return powerWithMod(a, m - 2, m);
}
void stringToUpper(string& strToConvert) {
  transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(),
            ::toupper);
}
void stringToLower(string& strToConvert) {
  transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(),
            ::tolower);
}
unordered_map<string, int> R;
int n, l, m;
string s;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> l >> s >> m;
  s += s;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    R[s] = i + 1;
  }
  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 = R.find(s.substr(ind + i * l, l));
      if (it == R.end() || mk[it->second]) {
        ok = 0;
        break;
      }
      mk[it->second] = 1;
      ans[i] = it->second;
    }
    if (ok) break;
  }
  if (!ok) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES" << endl;
  for (auto j : ans) cout << j << ' ';
  cout << "\n";
  return 0;
}
