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 <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;
#define DEBUG 0

#define st first
#define nd second

typedef pair<int,int> pun;
typedef long long ll;

long long mod = 998244353;

void fix(ll& x) {
	x %= mod;
	while (x < 0) x += mod;
}

void debug_vec(vector<ll>& v) {
	if (DEBUG) {
		for (auto x : v) cerr << x << " ";
		cerr <<"\n";
	}
}


int compute(const string& s) {
	map<string,int> pods;
	pods[""] = 1;
	for (char x : s) {
		map<string,int> npods = pods;
		for (pair<string,int> p : pods) {
			npods[p.first + x] += p.second;
		}
		pods = npods;
	}
	int cnt = 0;
	for (auto p : pods) if (p.second >= 2) cnt ++;
	return cnt % mod;
}

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