#include #include #include #include #include #include #define OP(s) cout<<#s<<"="<>m>>k; string s1,s2; map mp; while (n--) { map vd; cin>>s1>>s2; int len = s1.length(); for (int i = 0;i <= len-k;i++) { string tmp = ""; for (int j =0;j < k;j++) tmp += s1[i+j]; if (!vd[tmp]) { vd[tmp] = 1; int id; if (mp[tmp] == 0) { mp[tmp] = ++tota; id = tota; a[id].count = 0; a[id].yes = 0; a[id].str = tmp; } else id = mp[tmp]; a[id].count++; if (s2 == "Yes") a[id].yes++; } } } int ans = -1,ansc = 1,ansy = 2; for (int i = 1;i <= tota;i++) { if (a[i].count < m) continue; int y1 = a[i].yes,c1 = a[i].count; if (y1 * ansc < ansy*c1 || y1*ansc == ansy*c1 && c1 > ansc || y1*ansc == ansy*c1 && c1 == ansc && a[i].str < a[ans].str ) { ans = i,ansy = y1,ansc = c1; } } if (ans == -1) cout<<"No solution\n"; else cout<