#include <bits/stdc++.h>
using namespace std;
const unsigned long long base1 = 1e9 + 9;
const unsigned long long base2 = 1000;
unsigned long long keys1[100005], keys2[100005];
map<pair<unsigned long long, unsigned long long>, int> mp;
int a[2000005], vis[100005];
int main(int argc, const char *argv[]) {
  cin.sync_with_stdio(false);
  keys1[0] = keys2[0] = 1;
  for (int i = 1; i <= 100000; i++) {
    keys1[i] = keys1[i - 1] * base1;
    keys2[i] = keys2[i - 1] * base2;
  }
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s += s;
  int g;
  cin >> g;
  for (int i = 1; i <= g; i++) {
    string t;
    cin >> t;
    unsigned long long key1 = 0, key2 = 0;
    for (int j = 0; j < t.size(); j++) {
      key1 = key1 * base1 + (unsigned long long)t[j];
      key2 = key2 * base2 + (unsigned long long)t[j];
    }
    assert(!mp[make_pair(key1, key2)]);
    mp[make_pair(key1, key2)] = i;
  }
  unsigned long long key1 = 0, key2 = 0;
  for (int i = 0; i < s.size(); i++) {
    key1 = key1 * base1 + (unsigned long long)s[i];
    key2 = key2 * base2 + (unsigned long long)s[i];
    if (i >= k - 1) {
      a[i] = mp[make_pair(key1, key2)];
      key1 -= (unsigned long long)s[i - k + 1] * keys1[k - 1];
      key2 -= (unsigned long long)s[i - k + 1] * keys2[k - 1];
    }
  }
  for (int i = k - 1; i < 2 * k - 1; i++) {
    bool flag = true;
    for (int j = 0; j < n; j++) {
      if (a[j * k + i] == 0 || vis[a[j * k + i]]) {
        flag = false;
        break;
      }
      vis[a[j * k + i]] = 1;
    }
    if (flag) {
      cout << "YES" << endl;
      for (int j = 0; j < n; j++) {
        cout << a[j * k + i] << " ";
      }
      return 0;
    }
    for (int j = 0; j < n; j++) {
      if (a[j * k + i] != 0) {
        vis[a[j * k + i]] = 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}
