#include #include #include using namespace std; using namespace atcoder; using mint1 = static_modint<998244353>; using mint2 = static_modint<1000000007>; mint1 op1(mint1 a, mint1 b) { return a + b; } mint1 e1() { return 0; } mint1 ci1(char c) { return c - 'a' + 1; } mint2 op2(mint2 a, mint2 b) { return a + b; } mint2 e2() { return 0; } mint2 ci2(char c) { return c - 'a' + 1; } int main() { int n, l, q; cin >> n >> l >> q; vector pows1(l); vector pows2(l); pows1[0] = 1; pows2[0] = 1; for (int i = 1; i < l; i++) { pows1[i] = pows1[i - 1] * 30; pows2[i] = pows2[i - 1] * 30; } vector> seg1(n, segtree(l)); vector> seg2(n, segtree(l)); for (int i = 0; i < n; i++) { string s; cin >> s; for (int j = 0; j < l; j++) { seg1[i].set(j, ci1(s[j]) * pows1[j]); } for (int j = 0; j < l; j++) { seg2[i].set(j, ci2(s[j]) * pows2[j]); } } while (q--) { int T; cin >> T; if (T == 1) { int k; char c, d; cin >> k >> c >> d; k--; for (int i = 0; i < n; i++) { if (seg1[i].get(k) / pows1[k] == ci1(c)) { seg1[i].set(k, ci1(d) * pows1[k]); seg2[i].set(k, ci2(d) * pows2[k]); } } } else { string t; cin >> t; int tl = t.size(); mint1 hash1 = 0; mint2 hash2 = 0; for (int i = 0; i < tl; i++) { hash1 += ci1(t[i]) * pows1[i]; hash2 += ci2(t[i]) * pows2[i]; } int cnt = 0; for (int i = 0; i < n; i++) { if (seg1[i].prod(0, tl) == hash1 && seg2[i].prod(0, tl) == hash2) cnt++; } cout << cnt << '\n'; } } }