#include <bits/stdc++.h>
using namespace std;
const int mol = 1000000007;
const int maxn = 1000000 + 10;
string str;
map<string, int> Map;
int ans[maxn];
int vis[maxn];
int main() {
  int n, k, t;
  scanf("%d%d", &n, &k);
  cin >> str;
  str = str + str;
  scanf("%d", &t);
  memset(vis, -1, sizeof(vis));
  for (int i = 1; i <= t; i++) {
    string cc;
    cin >> cc;
    Map[cc] = i;
  }
  bool flag = false;
  for (int s = k - 1; s >= 0; s--) {
    int j;
    for (j = n - 1; j >= 0; j--) {
      string temp = str.substr(j * k + s, k);
      map<string, int>::iterator it = Map.find(temp);
      if (it == Map.end())
        break;
      else if (Map[temp] != 0 && vis[Map[temp]] == s)
        break;
      else {
        ans[j] = Map[temp];
        vis[Map[temp]] = s;
      }
    }
    if (j == -1) {
      flag = true;
      break;
    }
  }
  if (flag) {
    printf("YES\n");
    for (int i = 0; i < n; i++) {
      printf("%d ", ans[i]);
    }
    printf("\n");
  } else
    printf("NO\n");
  return 0;
}
