#include <bits/stdc++.h>
using namespace std;
int n, k, g, l;
unordered_map<string, int> game_index;
map<pair<long long, long long>, string> hash_game;
vector<int> result;
struct Hash {
  long long h[1200001], power[1200001], p, mod;
  Hash(long long p, long long mod) {
    this->p = p;
    this->mod = mod;
    power[0] = 1;
    for (int i = 1; i <= 1200000; i++) power[i] = (power[i - 1] * p) % mod;
  }
  void init(string s) {
    h[0] = 0;
    for (int i = 0; i < s.length(); i++)
      h[i + 1] = (h[i] + (s[i] - 'a' + 1) * power[i]) % mod;
  }
  long long get_hash(int i, int j) {
    return (((h[j + 1] + mod - h[i]) % mod) * power[l - i]) % mod;
  }
};
Hash h1(31, 1e9 + 7), h2(53, 1e9 + 7), h3(31, 1e9 + 7), h4(53, 1e9 + 7);
bool try_game(int first_index) {
  unordered_set<int> duplicate;
  result.clear();
  int i = first_index;
  for (int j = 1; j <= n; j++) {
    long long hash1 = h1.get_hash(i, i + k - 1),
              hash2 = h2.get_hash(i, i + k - 1);
    if (hash_game.count(pair<long long, long long>(hash1, hash2))) {
      int ind = game_index[hash_game[pair<long long, long long>(hash1, hash2)]];
      if (duplicate.count(ind)) return false;
      result.push_back(ind);
      duplicate.insert(ind);
      i += k;
    } else
      return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string cd, s;
  cin >> n >> k >> cd >> g;
  for (int i = 0; i < k; i++) cd += cd[i];
  l = cd.length();
  h1.init(cd);
  h2.init(cd);
  for (int i = 1; i <= g; i++) {
    cin >> s;
    game_index[s] = i;
    h3.init(s);
    h4.init(s);
    long long hash3 = h3.get_hash(0, s.length() - 1),
              hash4 = h4.get_hash(0, s.length() - 1);
    hash_game[pair<long long, long long>(hash3, hash4)] = s;
  }
  for (int i = 0; i < k; i++)
    if (try_game(i)) {
      cout << "YES\n";
      for (int j = 0; j < result.size(); j++) cout << result[j] << " ";
      cout << "\n";
      return 0;
    }
  cout << "NO\n";
  return 0;
}
