#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define MP make_pair #define PB push_back #define inf 1000000007 #define mod 1000000007 #define rep(i,n) for(int i = 0; i < (int)(n); ++i) void manacher(const string& S,vector& res) { int sz = (int)S.size(), i = 0, j = 0, k; res.resize(sz); while(i < sz){ while(i-j >= 0 && i+j < sz && S[i-j] == S[i+j]) j++; res[i] = j, k = 1; while(i-k >= 0 && i+k < sz && k+res[i-k] < j){ res[i+k] = res[i-k], k++; } i += k; j -= k; } } int main(){ ll n,k,q; cin >> n >> k >> q; string s; cin >> s; if(k==1){ vector p; manacher(s,p); rep(i,q){ ll a; cin >> a; a--; cout << 2*p[a]-1 << "\n"; } }else{ s = s+s+s; ll len = n*k; vector p; manacher(s,p); int m = s.size(); rep(i,q){ ll a; cin >> a; a--; if(a= len-n){ a -= n*(k-1); cout << 2*p[2*n+a]-1 << "\n"; }else{ ll b = a%n; b+=n; ll L = b; ll R = 3*n-b; ll t = p[b]; if(t==L||t==R){ cout << min(2*a+1,2*(len-a)-1) << "\n"; }else{ cout << 2*t-1 << "\n"; } } } } return 0; }