#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
int n, k, q;
string s;
int a[1005];
ui ksm(ui x, int y){
ui ans = 1;
while(y){
if(y&1)ans = ans * x;
y >>= 1;
x = x * x;
}
return ans;
}
int c[1005];
ui ans;
int m;
void dfs(int now){
if(now == n + 1){
for(int i = 1; i <= n; i++)a[i] = c[i];
int ok = 1;
for(int i = k - 1; i >= 0; i--){
if(m>>i&1);
else continue;
for(int j = n; j >= 0; j--){
if(j == 0){
ok = 0;
break;
}
if(j > 1 && s[j - 2] == 'A' && a[j] < (1<<i)){
ok = 0;
break;
}
if(a[j] >= (1<<i)){
a[j] -= (1<<i);
if(j > 1 && s[j - 2] == 'A'){
}else{
break;
}
}
}
}
ans += ok;
return;
}
for(int i = 0; i < (1<<k); i++){
c[now] = i;
dfs(now + 1);
}
}
ui dp[1005][1<<16];
int p[1<<16];
ui KSM[1005][105];
ui er[1005][1<<16][17];
int vis[1005][1<<16][17];
ui calc(int n, int m, int K){
if(n <= 1000 && m < (1<<16) && K <= 16){
if(vis[n][m][K])return er[n][m][K];
vis[n][m][K] = 1;
}
ui ans = 0;
for(int i = (n?min(31/n,K - 1):K-1); i >= 0; i--){
if(m>>i&1){
int num = __builtin_popcount(m>>i+1);
if(1ll * i * n < 32){
ans += ((ui)1 << i * n) * (bh==-1?ksm(n,num): KSM[bh][num]);
}
}
}
ans = -ans;
if(1ll * K * n < 32)ans += (ui)1<<K*n;
if(n <= 1000 && m < (1<<16) && K <= 16){
er[n][m][K] = ans;
}
return ans;
}
signed main(){
// freopen("dp.in", "r", stdin);
// freopen("dp.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin >> n >> k >> q;
cin >> s;
int ok = 1;
for(auto i : s){
if(i == 'A')ok = 0;
}
if(ok){
while(q--){
cin >> m;
cout << calc(n,m,k) << '\n';
}
return 0;
}
for(int i = 0; i < 1<<16; i++){
p[i] = k;
for(int j = 0; j < 16; j++){
if(i>>j&1){
p[i] = j;
break;
}
}
}
vector<int>vec;
for(int i = 1; i <= n; i++){
int en = i;
while(en + 1 <= n && s[en-1] != 'A')en++;
vec.emplace_back(en - i + 1);
i = en;
}
for(int i = 1; i <= vec.size(); i++){
for(int j = 0; j <= k; j++){
KSM[i][j] = ksm(vec[i-1] - (i!=1), j);
}
}
while(q--){
cin >> m;
for(int i = 0; i <= vec.size(); i++){
for(int j = 0; j < (1<<k); j++){
dp[i][j] = 0;
}
}
dp[vec.size()][m] = 1;
for(int i = vec.size(); i >= 1; i--){
for(int j = 0; j < (1<<k); j++){
if(!dp[i][j])continue;
for(int w = j; ; w = (w-1) & j){
int num = __builtin_popcount((j^w) >> p[w]);
dp[i - 1][w] += dp[i][j] * KSM[i][num] * calc(vec[i-1] - (i!=1), (j^w) & (1<<p[w])-1, p[w]) * (i==1?1:(ui)(((ui)1<<k)-w));
if(!w)break;
}
}
}
cout << dp[0][0] << '\n';
}
return 0;
}