1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#define ll long long

using namespace std;

ll count(string s){
    map<string,ll>m;
    ll i = 1;
    ll maks = (1<<s.length())-1;
    while(i<=maks){
        ll x = i;
        string t;
        int id = 0;
        while(x>0){
            if(x%2==1){
                t+=s[id];
            }
            x/=2;
            id++;
        }
        if(m.find(t)!=m.end()){
            m[t] = m[t]+1;
        }
        else{
            m[t]=1;
        }
        i++;
        
    }
    ll cnt=0;
    for (auto x : m){
        if(x.second>=2){
            cnt = (cnt+1)%998244353;
        }
    }
    return cnt;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,q;
    int p; char c;
    cin>>n>>q;
    string s;
    cin>>s;
    cout<<count(s)<<"\n";
    for(int i = 0;i<q;++i){
        cin>>p>>c;
        s[p-1]=c;
        cout<<count(s)<<"\n";
    }
    return 0;
}