#include using ll = std::int64_t; using T = std::tuple; template std::vector manacher(C seq){ auto n = seq.size(); std::vector res(n, 0); int c = 0; for(int i = 0; i < n; i += 1){ int ri = c - (i - c); if(ri >= 0 && i + res[ri] < c + res[c]){ res[i] = res[ri]; }else{ int j = c + res[c] - i; while(i - j >= 0 && i + j < n && seq[i - j] == seq[i + j]){ j += 1; } res[i] = j; c = i; } } return res; } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int T; std::cin >> T; for(int _=0;_> N >> M; std::string S1; std::cin >> S1; S1 = S1 + S1 + S1; std::string S2(S1.size() * 2, '$'); for(int i=0;i= M){return true;} } return false; } for(int i=N;i<2*N;i++){ if(L1[i] >= std::max(i - (N - 1), 2 * N - i)){ int r = std::min(2 * N - i, i - (N - 1)); ll c = 1ll * (1 + (x - 1) / 2 * 2) * (2 * r - 1) + 1ll * (x / 2 * 2) * (N - (2 * r - 1)); if(c >= M){ return true; } } } for(int i=N;i<2*N;i++){ int r = L2[i * 2 + 1] / 2; if(r >= std::max(i - (N - 1), 2 * N - (i + 1))){ int r2 = std::min(2 * N - (i + 1), i - (N - 1)); ll c = 1ll * (1 + (x - 1) / 2 * 2) * (2 * r2) + 1ll * (x / 2 * 2) * (N - (2 * r2)); if(c >= M){ return true; } } } int r = L2[(2 * N - 1) * 2 + 1] / 2; if(r >= N){ ll c = 1ll * (x / 2) * (2 * N); if(c >= M){ return true; } } return false; }; if(check(2'000'000'000)){ int ok = 2'000'000'000, ng = 0; while(ok - ng >= 2){ int m = (ok + ng) / 2; if(check(m)){ ok = m; }else{ ng = m; } } std::cout << ok << std::endl; }else{ std::cout << -1 << std::endl; } } }