#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 3;
char s[N], t[N];
int n, trie[N][26], cnt, fail[N], k, g, en[N], match[N], las[N], st[N], top;
void insert(int o) {
  int now = 0;
  for (int i = 1, c; i <= k; i++) {
    c = t[i] - 'a';
    if (trie[now][c] == 0) trie[now][c] = ++cnt;
    now = trie[now][c];
  }
  en[now] = o;
}
void build() {
  queue<int> q;
  for (int i = 0; i < 26; i++)
    if (trie[0][i]) q.push(trie[0][i]);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = 0; i < 26; i++) {
      if (trie[now][i]) {
        q.push(trie[now][i]);
        fail[trie[now][i]] = trie[fail[now]][i];
      } else
        trie[now][i] = trie[fail[now]][i];
    }
  }
}
int main() {
  scanf("%d %d %s %d", &n, &k, s + 1, &g);
  int sl = n * k, l = sl + k;
  for (int i = 1; i <= k; i++) s[i + sl] = s[i];
  for (int i = 1; i <= g; i++) {
    scanf("%s", t + 1);
    insert(i);
  }
  build();
  int now = 0;
  for (int i = 1; i <= l; i++) {
    while (now && trie[now][s[i] - 'a'] == 0) now = fail[now];
    now = trie[now][s[i] - 'a'];
    if (en[now]) match[i - k + 1] = en[now];
  }
  int cnt = 0, f = 0, ok = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = i, c = 1; c <= n; c++, j += k) {
      if (!match[j]) {
        cnt = 0;
        break;
      }
      if (las[match[j]] == 0) {
        cnt++;
        las[match[j]] = i;
        st[++top] = match[j];
      } else
        break;
      if (cnt == n) {
        ok = i;
        break;
      }
    }
    if (ok) break;
    for (int i = 1; i <= top; i++) las[st[i]] = 0;
    top = 0;
    cnt = 0;
    f = 0;
  }
  if (ok) {
    printf("YES\n");
    for (int i = 1; i <= n; i++) printf("%d ", match[ok]), ok += k;
  } else
    printf("NO");
  return 0;
}
