// Errichto
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
const int pot = 1024 * 1024;
const int mod = 1e9 + 7;
const char actg[5] = "ACTG";
struct M {
int t[4][4];
M() { REP(i,4)REP(j,4) t[i][j] = 0; }
M operator * (const M & b) const {
M ans;
REP(i,4)REP(j,4)REP(k,4)
ans.t[i][k] = (ans.t[i][k] + (long long) t[i][j] * b.t[j][k]) % mod;
return ans;
}
} m[2 * pot];
void fill(char letter, M & mat) {
int c = -1;
REP(j, 4) if(actg[j] == letter) c = j;
assert(c != -1);
REP(i,4) REP(j,4) if(i != j) mat.t[i][j] = 0;
REP(j, 4) if(j != c) mat.t[c][j] = 1;
}
char sl[pot];
int main() {
int n, q;
scanf("%d%d", &n, &q);
scanf("%s", sl);
REP(i, pot) REP(j, 4) m[pot+i].t[j][j] = 1;
REP(i, n) fill(sl[i], m[pot+i]);
for(int i = pot - 1; i >= 1; --i) m[i] = m[2*i] * m[2*i+1];
while(q--) {
int ii;
char z;
scanf("%d %c", &ii, &z);
ii = pot + ii - 1;
fill(z, m[ii]);
for(int i = ii / 2; i >= 1; i /= 2)
m[i] = m[2*i] * m[2*i+1];
int s = 0;
REP(i,4) REP(j,4) s = (s + m[1].t[i][j]) % mod;
// we need (s - 1) / 3
s = (s + mod - 1) % mod;
int inv = 333333336;
assert(inv * 3LL % mod == 1);
s = (long long) inv * s % mod;
printf("%d\n", s);
}
return 0;
}
Ly8gRXJyaWNodG8KI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBGT1IoaSxhLGIpIGZvcihpbnQgaSA9IChhKTsgaSA8PSAoYik7ICsraSkKI2RlZmluZSBSSShpLG4pIEZPUihpLDEsKG4pKQojZGVmaW5lIFJFUChpLG4pIEZPUihpLDAsKG4pLTEpCgpjb25zdCBpbnQgcG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