import sys input = sys.stdin.readline class SegmentTree: def __init__(self, n, identity_e, combine_f, ): self._n = n self._size = 1 while self._size < self._n: self._size <<= 1 self._identity_e = identity_e self._combine_f = combine_f self._node = [self._identity_e] * (2 * self._size) def build(self, array): assert len(array) == self._n for index, value in enumerate(array, start=self._size): self._node[index] = value for index in range(self._size - 1, 0, -1): self._node[index] = self._combine_f( self._node[index << 1 | 0], self._node[index << 1 | 1] ) def update(self, index, value): i = self._size + index self._node[i] = value while i > 1: i >>= 1 self._node[i] = self._combine_f( self._node[i << 1 | 0], self._node[i << 1 | 1] ) def fold(self, L, R): L += self._size R += self._size value_L = self._identity_e value_R = self._identity_e while L < R: if L & 1: value_L = self._combine_f(value_L, self._node[L]) L += 1 if R & 1: R -= 1 value_R = self._combine_f(self._node[R], value_R) L >>= 1 R >>= 1 return self._combine_f(value_L, value_R) def get(self, p): return self._node[p + self._size] def max_right(self, l, f): assert 0 <= l <= self._n assert f(self._identity_e) if l == self._n: return self._n l += self._size sm = self._identity_e while True: while l % 2 == 0: l >>= 1 if not f(self._combine_f(sm, self._node[l])): while l < self._size: l <<= 1 if f(self._combine_f(sm, self._node[l])): sm = self._combine_f(sm, self._node[l]) l += 1 return l - self._size sm = self._combine_f(sm, self._node[l]) l += 1 if l & -l == l: break return self._n def min_left(self, r, f): assert 0 <= r <= self._n assert f(self._identity_e) if r == 0: return 0 r += self._size sm = self._identity_e while True: r -= 1 while r > 1 and r % 2: r >>= 1 if not f(self._combine_f(self._node[r], sm)): while r < self._size: r = 2 * r + 1 if f(self._combine_f(self._node[r], sm)): sm = self._combine_f(self._node[r], sm) r -= 1 return r + 1 - self._size sm = self._combine_f(self._node[r], sm) if r & -r == r: break return 0 def __str__(self): temp = [] for i in range(self._n): temp.append(str(self.fold(i, i + 1))) return ' '.join(temp) N, L, Q = map(int, input().split()) base = 4649 mod = 10**16 + 61 p = [1] * (L + 1) for i in range(L): p[i + 1] = p[i] * base % mod def op(x, y): a = (x[0] * p[y[1]] + y[0]) % mod b = x[1] + y[1] return (a, b) T = [SegmentTree(L + 1, (0, 0), op) for i in range(N)] S = [] for i in range(N): S.append(list(input().rstrip())) for j in range(L): T[i].update(j, (ord(S[i][j]) - ord("a"), 1)) for q in range(Q): query = list(input().split()) if query[0] == "1": b, c, d = query[1:] b = int(b) - 1 for i in range(N): if S[i][b] == c: S[i][b] = d T[i].update(b, (ord(d) - ord("a"), 1)) else: b = query[1] v = 0 for c in b: v *= base v += ord(c) - ord("a") v %= mod ans = 0 for i in range(N): if v == T[i].fold(0, len(b))[0]: ans += 1 print(ans)