#include using namespace std; #include using namespace atcoder; #ifdef DEFINED_ONLY_IN_LOCAL #include #define dump(...) cpp_dump(__VA_ARGS__) #else #undef dump #define dump(...) #endif #define rep1(a) for (int i = 0; i < a; i++) #define rep2(i, a) for (int i = 0; i < a; i++) #define rep3(i, a, b) for (int i = a; i < b; i++) #define rep4(i, a, b, c) for (int i = a; i < b; i += c) #define overloadRep(a, b, c, d, e, ...) e #define rep(...) overloadRep(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define endl '\n' #define INT(...) int __VA_ARGS__; input(__VA_ARGS__) #define LL(...) ll __VA_ARGS__; input(__VA_ARGS__) using ll = long long; using ull = unsigned long long; const int inf = 1e9; const ll INF = 1e18; const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0}; const int ddx[8] = {1, 0, -1, 0, 1, -1, 1, -1}; const int ddy[8] = {0, 1, 0, -1, 1, -1, -1, 1}; struct cincout {cincout() {ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15);}} init; template void input(T&... a) {(cin >> ... >> a);} template inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;} template inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;} template istream& operator>>(istream& is, pair& p) {is >> p.first >> p.second; return is;} template ostream& operator<<(ostream& os, const pair& p) {os << p.first << " " << p.second << '\n'; return os;} template istream& operator>>(istream& is, vector& v) {for (T& in : v) {is >> in;} return is;} template ostream& operator<<(ostream& os, const vector& v) {rep(i, (int)v.size()) {os << v[i] << " \n"[i + 1 == (int)v.size()];} return os;} template istream& operator>>(istream& is, vector>& vv) {for (vector& v : vv) {is >> v;} return is;} template ostream& operator<<(ostream& os, vector>& vv) {for (vector& v : vv) {os << v;} return os;} template inline T max(vector x) {return *max_element(x.begin(), x.end());} template inline T min(vector x) {return *min_element(x.begin(), x.end());} template inline T sum(vector x) {return reduce(x.begin(), x.end());} template constexpr auto min(T... a) {return min(initializer_list>{a...});} template constexpr auto max(T... a) {return max(initializer_list>{a...});} inline bool bit(ll x, int p) {return (x >> p) & 1;} inline bool out(int ni, int nj, int h, int w) {return (ni < 0 or ni >= h or nj < 0 or nj >= w);} inline int pc(ll x) {return __builtin_popcountll(x);} void Yes(bool judge = true) {cout << (judge ? "Yes" : "No") << endl;} void No(bool judge = true) {cout << (judge ? "No" : "Yes") << endl;} using namespace std; #include random_device rd; mt19937_64 rnd(rd()); static constexpr long long mod = (1LL << 61) - 1; static const long long base = rnd() % (mod - 4) + 2; using D = pair; D op(D l, D r) { auto [a, b] = l; auto [c, d] = r; __int128_t x = (__int128_t)a * d + c; return D(x % mod, ((__int128_t)b * d) % mod); } D e() { return D(0, 1); } D op_(D l, D r) { auto [a, b] = l; auto [c, d] = r; __int128_t x = (__int128_t)c * b + a; return D(x % mod, ((__int128_t)b * d) % mod); } struct RollingHashTree { segtree seg; segtree rseg; bool reverse; explicit RollingHashTree(const string &s = "", bool reverse_ = false) : reverse(reverse_) { int n = s.size(); seg = segtree(n); if (reverse) rseg = segtree(n); rep(i, n) { seg.set(i, D(s[i], base)); if (reverse) rseg.set(i, D(s[i], base)); } } inline void set(int i, char c) { seg.set(i, D(c, base)); if (reverse) rseg.set(i, D(c, base)); } inline long long get(int l, int r) { auto [a, b] = seg.prod(l, r); return a; } inline long long rget(int l, int r) { auto [a, b] = rseg.prod(l, r); return a; } }; int main() { int n, l, q; cin >> n >> l >> q; vector s(n); cin >> s; vector rolling_hash(n); rep(i, n) { rolling_hash[i] = RollingHashTree(s[i]); } while (q--) { int type; cin >> type; if (type == 1) { int k; char c, d; cin >> k >> c >> d; k--; rep(i, n) { if (s[i][k] == c) { s[i][k] = d; rolling_hash[i].set(k, d); } } } else { string t; cin >> t; int m = t.size(); RollingHashTree rol(t); int ans = 0; rep(i, n) { if (rolling_hash[i].get(0, m) == rol.get(0, m)) ans++; } cout << ans << endl; } } return 0; }