import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    static final int BASE = 343;
    static final int MOD = 1000000009;
    static long[] values;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int length = sc.nextInt();
        int q = sc.nextInt();
        values = new long[length];
        values[0] = 60;
        for (int i = 1; i < length; i++) {
            values[i] = values[i - 1] * BASE % MOD;
        }
        char[][] inputs = new char[n][];
        SegmentTree[] sts = new SegmentTree[n];
        for (int i = 0; i < n; i++) {
            inputs[i] = sc.next().toCharArray();
            sts[i] = new SegmentTree(length);
            for (int j = 0; j < length; j++) {
                sts[i].add(j, (inputs[i][j] - 'a' + 1) * values[j] % MOD);
            }
        }
        StringBuilder sb = new StringBuilder();
        while (q-- > 0) {
            if (sc.nextInt() == 1) {
                int idx = sc.nextInt() - 1;
                char left = sc.next().charAt(0);
                char right = sc.next().charAt(0);
                for (int i = 0; i < n; i++) {
                    if (inputs[i][idx] == left) {
                        inputs[i][idx] = right;
                        sts[i].add(idx, (right - left + MOD) % MOD * values[idx] % MOD);
                    }
                }
            } else {
                long ans = 0;
                char[] current = sc.next().toCharArray();
                for (int i = 0; i < current.length; i++) {
                    ans += (current[i] - 'a' + 1) * values[i] % MOD;
                    ans %= MOD;
                }
                int count = 0;
                for (int i = 0; i < n; i++) {
                    if (sts[i].getValue(current.length) == ans) {
                        count++;
                    }
                }
                sb.append(count).append("\n");
            }
        }
        System.out.print(sb);
    }
    
    static class SegmentTree {
        int size;
        long[] values;
        
        public SegmentTree(int x) {
            size = 2;
            while (size < x) {
                size <<= 1;
            }
            values = new long[size * 2 - 1];
        }
        
        public void add(int idx, long v) {
            int current = idx + size - 1;
            values[current] += v;
            values[current] %= MOD;
            calc((current - 1) / 2);
        } 
        
        private void calc(int idx) {
            values[idx] = (values[idx * 2 + 1] + values[idx * 2 + 2]) % MOD;
            if (idx > 0) {
                calc((idx - 1) / 2);
            }
        }
        
        public long getValue(int right) {
            return getValue(0, 0, size, right);
        }
        
        private long getValue(int idx, int min, int max, int right) {
            if (max <= right) {
                return values[idx];
            } else if (min >= right) {
                return 0;
            } else {
                return (getValue(idx * 2 + 1, min, (min + max) / 2, right) 
                    + getValue(idx * 2 + 2, (min + max) / 2, max, right)) % MOD;
            }
        }
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}