#include <bits/stdc++.h>
using namespace std;
int pct(int x) { return __builtin_popcount(x); }
int pct(long long x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); }
int bt(long long x) { return 63 - __builtin_clzll(x); }
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
long long cdiv(long long a, long long b) {
  return a / b + !(a < 0 || a % b == 0);
}
int nxt_C(int x) {
  int c = x & -x, r = x + c;
  return (((r ^ x) >> 2) / c) | r;
}
long long nxt_C(long long x) {
  long long c = x & -x, r = x + c;
  return (((r ^ x) >> 2) / c) | r;
}
vector<int> get_bits(int mask) {
  vector<int> bb;
  while (mask) {
    int b = bt(mask);
    bb.push_back(b);
    mask ^= (1 << b);
  }
  reverse(bb.begin(), bb.end());
  return bb;
}
int get_mask(vector<int> v) {
  int mask = 0;
  for (int x : v) {
    mask ^= (1 << x);
  }
  return mask;
}
template <typename T>
void uniq(vector<T> &v) {
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
}
template <typename T>
void leftShift(vector<T> &v, long long k) {
  k %= (int)v.size();
  if (k < 0) k += (int)v.size();
  rotate(v.begin(), v.begin() + k, v.end());
}
template <typename T>
void rightShift(vector<T> &v, long long k) {
  leftShift(v, (int)v.size() - k);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand(long long l, long long r) {
  uniform_int_distribution<long long> uid(l, r);
  return uid(rng);
}
void sc() {}
template <typename Head, typename... Tail>
void sc(Head &H, Tail &...T) {
  cin >> H;
  sc(T...);
}
string to_string(__int128 x) {
  string s = "";
  bool neg = 0;
  if (x < 0) {
    s += "-";
    neg = 1;
    x = -x;
  }
  if (!x) s += '0';
  while (x) {
    int rem = x % 10;
    s += to_string(rem);
    x /= 10;
  }
  reverse(s.begin() + neg, s.end());
  return s;
}
const int mod = 1e9 + 7;
int pwr(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * 1LL * a) % mod;
    a = (a * 1LL * a) % mod;
    b >>= 1;
  }
  return ans;
}
const int CHAR = 26;
class AhoCora {
 public:
  struct Node {
    unordered_map<int, int> ch;
    int link;
    int id;
    unordered_map<int, int> go;
  };
  int get_ch(int u, int c) {
    if (!nd[u].ch.count(c)) return -1;
    return nd[u].ch[c];
  }
  int get_go(int u, int c) {
    if (!nd[u].go.count(c)) return -1;
    return nd[u].go[c];
  }
  vector<Node> nd;
  vector<int> Q;
  int qs, qe;
  int size;
  int createNode() {
    int ret = size++;
    nd.emplace_back();
    Q.emplace_back();
    nd[ret].id = 0;
    return ret;
  }
  void init() {
    size = 0;
    nd.clear();
    Q.clear();
    createNode();
  }
  template <typename A>
  void add(A str, const int &sz, int &id) {
    int cur = 0;
    for (int i = 0; i < sz; i++) {
      int c = str[i] - 'a';
      if (get_ch(cur, c) == -1) {
        int nnd = createNode();
        nd[cur].ch[c] = nnd;
      }
      cur = get_ch(cur, c);
    }
    nd[cur].id = id;
  }
  inline int next(int u, int c) {
    if (get_go(u, c) != -1) return get_go(u, c);
    int uu = u;
    while (u && get_ch(u, c) < 0) u = nd[u].link;
    return nd[uu].go[c] = (get_ch(u, c) < 0) ? 0 : get_ch(u, c);
  }
  void computelink() {
    qs = qe = 0;
    nd[0].link = 0;
    for (int x, i = 0; i < CHAR; i++) {
      if ((x = get_ch(0, i)) >= 0) {
        Q[qe++] = x;
        nd[x].link = 0;
      }
    }
    while (qs < qe) {
      int u = Q[qs++];
      for (int v, i = 0; i < CHAR; i++) {
        if ((v = get_ch(u, i)) >= 0) {
          Q[qe++] = v;
          int m = nd[u].link;
          int L = nd[v].link = next(m, i);
        }
      }
    }
  }
} acc;
const int N = 2e6 + 5;
int mark[N];
bitset<N> taken;
void solve() {
  int n, k;
  sc(n, k);
  string s;
  sc(s);
  int tot = n * k;
  s += s;
  int g;
  sc(g);
  acc.init();
  for (int i = 1; i <= g; i++) {
    string p;
    sc(p);
    acc.add(p, (int)p.size(), i);
  }
  acc.computelink();
  int cur = 0;
  for (int i = 0; i <= 2 * tot - 1; i++) {
    cur = acc.next(cur, s[i] - 'a');
    if (acc.nd[cur].id) {
      mark[i] = acc.nd[cur].id;
      if (i >= tot) mark[i - tot] = mark[i];
      42;
    }
  }
  vector<int> z;
  for (int j = 0; j <= k - 1; j++) {
    int pos = j;
    z.clear();
    for (int i = 1; i <= n; i++) {
      if (mark[pos] && !taken[mark[pos]]) {
        z.push_back(mark[pos]);
        taken[mark[pos]] = 1;
      } else
        break;
      pos += k;
    }
    pos = j;
    for (int i = 1; i <= n; i++) {
      taken[mark[pos]] = 0;
      pos += k;
    }
    if ((int)z.size() == n) {
      cout << "YES" << '\n';
      for (int x : z) {
        cout << x << " ";
      }
      return;
    }
  }
  cout << "NO";
}
signed main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int tt = 1; tt <= t; tt++) {
    solve();
  }
  return 0;
}
