#include using namespace std; using ll = long long; constexpr ll INF = 1LL<<60; class RollingHash{ 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+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*3), r+(N*3)); }; auto get_b = [&](int l, int r) -> pair{ return b.get((N*3)-r, (N*3)-l); }; auto cnt = [&](ll l, ll r) -> ll{ if(l<0){ l = -(abs(l+1)/N+1); }else{ l = l/N; } if(r<0){ r = -(abs(r+1)/N+1); }else{ r = r/N; } return r-l; }; ll ans = INF; // even if((M+1)/2<=N){ ll len = (M+1)/2; for(int i=0; i> T; for(;T--;) solve(); return 0; }