<span>codeforces727E Games on a CD</span>
/* *********************************************** Author :devil ************************************************ */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <stack> #include <map> #include <unordered_map> #include <string> #include <time.h> #include <cmath> #include <stdlib.h> #define LL long long #define rep(i,a,b) for(int i=a;i<=b;i++) #define dep(i,a,b) for(int i=a;i>=b;i--) #define ou(a) printf("%d\n",a) #define pb push_back #define pii pair<int,int> #define mkp make_pair #define IN freopen("in.txt","r",stdin); #define OUT freopen("out.txt","w",stdout); using namespace std; const int inf=0x3f3f3f3f; const int mod=1e9+7; const int N=1e5+10; unordered_map<string,int>mp; int n,l,m; string s,u; int main() { cin>>n>>l>>s>>m; s+=s; for(int i=1;i<=m;i++) { cin>>u; mp[u]=i; } int L=n*l; bool ok; vector<int>ans(n,0); for(int ind=L-l;ind<L;ind++) { ok=1; vector<bool>mk(m+1,0); for(int i=0;i<n&&ok;i++) { auto it=mp.find(s.substr(ind+i*l,l)); if(it==mp.end()||mk[it->second]) { ok=0; break; } mk[it->second]=1; ans[i]=it->second; } if(ok) break; } if(!ok) printf("NO\n"); else { printf("YES\n"); for(auto j:ans) printf("%d ",j); } return 0; }