func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 3000000 + 7;   const int M = 1500 + 7;   const int inf = 1e9 + 7;   const long long linf = 1ll * inf * (inf - 1);   const double pi = acos(-1);   const double eps = 1e-6;   const bool multipleTest = false;   const int mod[2] = {inf, 984723593 + 7};   const int gen[2] = {(rand() % inf) + 1, (rand() % 92473247) + 1};   long long f[2][N];   void init() {     f[0][0] = f[1][0] = 1;     for (int i = 1; i < N; ++i) {       for (int t = 0; t < 2; ++t)         f[t][i] = (long long)f[t][i - 1] * gen[t] % mod[t];     }   }   pair<int, int> val[N];   pair<int, int> getNext(pair<int, int> cur, pair<int, int> nxt, int len) {     int fir = (cur.first * f[0][len] + nxt.first) % mod[0];     int sec = (cur.second * f[1][len] + nxt.second) % mod[1];     return make_pair(fir, sec);   }   pair<int, int> getVal(int u, int v) {     ++u;     ++v;     long long fir = (val[v].first - val[u - 1].first * f[0][v - u + 1]) % mod[0];     if (fir < 0) fir += mod[0];     long long sec =         (val[v].second - val[u - 1].second * f[1][v - u + 1]) % mod[1];     if (sec < 0) sec += mod[1];     return make_pair(fir, sec);   }   int n, k;   string s;   map<pair<int, int>, int> all;   int ans[N];   set<int> has;   void solve() {     init();     cin >> n >> k;     cin >> s;     int m;     cin >> m;     for (int i = 0; i < m; ++i) {       string x;       cin >> x;       pair<int, int> cur = make_pair(0, 0);       for (int j = 0, len = (int)(x).size(); j < len; ++j) {         cur = getNext(cur, make_pair(x[j], x[j] + 2), 1);       }       all[cur] = i + 1;     }     for (int t = 0; t < k; ++t) s += s[t];     val[0] = make_pair(0, 0);     for (int i = 1, len = (int)(s).size(); i <= len; ++i) {       val[i] = getNext(val[i - 1], make_pair(s[i - 1], s[i - 1] + 2), 1);     }     for (int i = 0; i < k; ++i) {       bool ok = true;       int t = 0;       has.clear();       for (int j = i; t < n; j += k) {         pair<int, int> cur = getVal(j, j + k - 1);         if (!all.count(cur) || has.count(all[cur])) {           ok = false;           break;         } else {           ans[t++] = all[cur];           has.insert(ans[t - 1]);         }       }       if (ok) {         puts( YES );         for (int j = 0; j < n; ++j) {           printf( %d  , ans[j]);         }         return;       }     }     puts( NO );   }   int main() {     int Test = 1;     if (multipleTest) {       cin >> Test;     }     for (int i = 0; i < Test; ++i) {       solve();     }   }   