#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
using namespace std;
const int MAXN = 2e5 + 99;
const ll MOD = 1e9 + 7;
int t[MAXN];
int g[MAXN][3];
int cntN;
pair<int,int> cntZ,cntC;
int n,q;
void pre(){
g[0][0] = 0;
g[0][1] = 1;
g[0][2] = 1;
for(int i = 1; i < MAXN; i++){
g[i][0] = (g[i-1][1] + g[i-1][2]) % MOD;
g[i][1] = (g[i-1][0] + g[i-1][2]) % MOD;
g[i][2] = (g[i-1][0] + g[i-1][1]) % MOD;
}
}
void solve(){
int sumZ = cntZ.F + cntZ.S;
int sumC = cntC.F + cntC.S;
ll wynik = (g[cntN][((sumZ - sumC) % 3 + 3 ) % 3]);
if(cntZ.F == 0 && cntC.S == 0 && n % 2 != 0 && n > 1)
wynik--;
if(cntZ.S == 0 && cntC.F == 0 && n % 2 != 0 && n > 1)
wynik--;
cout << max(wynik,(ll)0) << "\n";
}
int main(){
cntN = 0;
cntZ = cntC = {0,0};
cin >> n >> q;
pre();
for(int i = 0; i < n; i++){
char c;
cin >> c;
if(c == 'C'){
t[i] = 0;
cntC.F += (i % 2 == 0);
cntC.S += (i % 2 == 1);
}else if(c == 'Z'){
t[i] = 1;
cntZ.F += (i % 2 == 0);
cntZ.S += (i % 2 == 1);
}else if(c == 'N'){
t[i] = 2;
cntN++;
}
}
solve();
for(int i = 0; i < q; i++){
int j;
char c;
cin >> j >> c;
if(t[j-1] == 0){
cntC.F -= ((j - 1) % 2 == 0);
cntC.S -= ((j - 1) % 2 == 1);
}else if(t[j-1] == 1){
cntZ.F -= ((j - 1) % 2 == 0);
cntZ.S -= ((j - 1) % 2 == 1);
}else if(t[j-1] == 2){
cntN--;
}
if(c == 'C'){
t[j - 1] = 0;
cntC.F += ((j - 1) % 2 == 0);
cntC.S += ((j - 1) % 2 == 1);
}else if(c == 'Z'){
t[(j - 1)] = 1;
cntZ.F += ((j - 1) % 2 == 0);
cntZ.S += ((j - 1) % 2 == 1);
}else if(c == 'N'){
t[(j - 1)] = 2;
cntN++;
}
solve();
}
}