#include using namespace std; using ll = long long; constexpr ll INF = 1LL<<60; class RollingHash{ using ll = long long; private: static const ll mod1=888888901, mod2=987654323; ll base1, base2; int n; vector hash1, hash2, pow1, pow2; public: RollingHash(const string &s, const ll _base1=2525, const ll _base2=4649): base1(_base1), base2(_base2) { n = s.length(); hash1.assign(n+1, 0); hash2.assign(n+1, 0); pow1.assign(n+1, 1); pow2.assign(n+1, 1); for (int i=0; i get(const int l, const int r) const{ ll fi = hash1[r]-(hash1[l]*pow1[r-l]%mod1); if(fi<0) fi += mod1; ll se = hash2[r]-(hash2[l]*pow2[r-l]%mod2); if(se<0) se += mod2; return make_pair(fi,se); } pair merge(const pair a, const pair b, const int b_len) const{ ll fi = ((a.first*pow1[b_len])%mod1 + b.first) % mod1; ll se = ((a.second*pow2[b_len])%mod2 + b.second) % mod2; return make_pair(fi, se); } }; void solve(){ int N; cin >> N; ll M; cin >> M; string S; cin >> S; string s = S+S+S+S; string r = s; reverse(r.begin(), r.end()); RollingHash a(s), b(r); auto get_a = [&](int l, int r) -> pair{ return a.get(l+N*2, r+N*2); }; auto get_b = [&](int l, int r) -> pair{ return b.get(N*2-r, N*2-l); }; auto cnt = [&](ll l, ll r) -> ll{ return ((r-1)/N) - (l/N) + 1; }; ll ans = INF; // even if((M+1)/2> T; for(;T--;) solve(); return 0; }