class BIT: def __init__(self,n,M): self.s=n self.d=[0]*n self.m=M return def update(self,p,x): p+=1 while p<=self.s: self.d[p-1]+=x self.d[p-1]%=self.m p+=p&(-p) return def getsum(self,p): p+=1 a=0 while p>0: a+=self.d[p-1] a%=self.m p-=p&(-p) return a B1=1007 M1=1000000007 P1=[1] for i in range(1,3001): P1+=[P1[-1]*B1%M1] R1=[1,pow(B1,M1-2,M1)] for i in range(2,3001): R1+=[R1[-1]*R1[1]%M1] n,l,q=map(int,input().split()) S=[] s1=[] hs1=[] for i in range(n): s=input() S+=[list(s)] s1+=[BIT(l,M1)] hs1+=[[0]*(l+1)] for j in range(l): hs1[i][j]=ord(s[j])*P1[j]%M1 hs1[i][j]+=hs1[i][j-1] hs1[i][j]%=M1 for _ in range(q): query=input().split() if int(query[0])==1: _,k,c,d=query k=int(k)-1 c=ord(c) d=ord(d) for i in range(n): if ord(S[i][k])==c: s1[i].update(k,(-c+d)*P1[k]%M1) S[i][k]=chr(d) else: _,t=query t=list(t) ht1=0 for i in range(len(t)): ht1+=ord(t[i])*P1[i] ht1%=M1 g=0 for i in range(n): if (s1[i].getsum(len(t)-1)+hs1[i][len(t)-1])%M1==ht1: g+=1 print(g)