#include <bits/stdc++.h>
#include <atcoder/segtree>

using namespace std;
using ll = long long;
using namespace atcoder;

mt19937_64 rng(time(0));
const ll B=1;
ll MOD[B] = {998244353};
ll BASE[B] = {static_cast<ll>(rng() % MOD[0])};

//Rolling Hash on Segment Tree
struct Record{
    ll hash, pow;
};

using S = array<Record, B>;
S op(S a, S b){
    S res;
    for (int i=0; i<B; i++){
        res[i] = {(a[i].hash * b[i].pow % MOD[i] + b[i].hash) % MOD[i], (a[i].pow * b[i].pow)%MOD[i]};
    }
    return res;
}

S e() {
    S res;
    for (int i=0; i<B; i++) res[i] = {0,1};
    return res;
}

S gen(int x){
    S res;
    for (int i=0; i<B; i++) res[i] = {x, BASE[i]};
    return res;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    /*
       tがSの接頭辞であるか?
       t[1:|T|]=S[1:|T|]
       Rolling Hash
    */

    ll N, L, Q, t, k;
    char c, d;
    string T;
    cin >> N >> L >> Q;
    vector<string> s(N);
    vector<segtree<S, op, e>> tree;

    auto to_hash=[&](string &s){
        S x;
        int N=s.size();
        vector<S> v(N);
        for (int i=0; i<N; i++){
            x = gen(s[i]-'a');
            v[i] = x;
        }
        return segtree<S, op, e>(v);
    };

    vector p(B, vector<ll>(L));
    
    for (int i=0; i<B; i++){
        p[i][0] = 1;
        for (int j=1; j<L; j++){
            p[i][j] = p[i][j-1] * BASE[i];
            p[i][j] %= MOD[i];
        }
    }
    
    auto to_hash2=[&](string &t){
        vector<ll> res(B);

        for (int i=0; i<B; i++){
            for (int j=0; j<t.size(); j++){
                res[i] += (p[i][t.size()-1-j] * (t[j]-'a')) % MOD[i];
                res[i] %= MOD[i];
            }
        }
        return res;
    };
    
    for (int i=0; i<N; i++){
        cin >> s[i];
        tree.push_back(to_hash(s[i]));
    };

    while(Q--){
        cin >> t;
        if (t == 1){
            cin >> k >> c >> d;
            k--;
            for (int i=0; i<N; i++){
                if (s[i][k] == c){
                    s[i][k] = d;
                    tree[i].set(k, gen(d-'a'));
                }
            }
        }
        else{
            cin >> T;
            int ans=0;
            vector<ll> x = to_hash2(T);
            for (int i=0; i<N; i++){
                bool f=1;
                S y = tree[i].prod(0, T.size());
                for (int j=0; j<B; j++) f &= (x[j] == y[j].hash);
                ans += f;
            }
            cout << ans << endl;
        }
    }

    return 0;
}