#include using namespace std; template struct dynamic_rolling_hash { using dat=array; dynamic_rolling_hash():dynamic_rolling_hash(0,0){} dynamic_rolling_hash(int _n, long long _b):dynamic_rolling_hash(vector(_n)){} dynamic_rolling_hash(const vector&_v):n(_v.size()) { init(); log=0; while((1<=1;i--)update(i); } static void set_base(long long b){base=b;} void set(int p, S x) { p+=sz; for(int j=0;j<5;j++)node[p].first[j]=inner_hash(x,j); node[p].second=1; for(int i=1;i<=log;i++)update(p>>i); } pair prod(int l, int r) { auto pl=e(),pr=e(); l+=sz,r+=sz; while(l>=1,r>>=1; } return op(pl,pr); } pair all_prod(){return node[1];} private: int n,log,sz; static long long base; static constexpr dat mod=dat{94663399,993272689,998700149,1000001087,1000100033}; static vectormod_pow; vector>node; long long inner_hash(S x, int p){return (base^(base-x))%mod[p];} pairop(const pair&a, const pair&b) { dat c; for(int i=0;i<5;i++)c[i]=(a.first[i]+b.first[i]*mod_pow[a.second][i])%mod[i]; return make_pair(c,a.second+b.second); } paire(){return make_pair(dat(),0);} void update(int p){node[p]=op(node[2*p],node[2*p+1]);} void init() { assert(base>0); if(int(mod_pow.size())>=n)return; int d=mod_pow.size(); mod_pow.resize(max(n+1,2*d)); for(int i=d;i vector>dynamic_rolling_hash::mod_pow(1,{1,1,1,1,1}); template long long dynamic_rolling_hash::base=-1; int N,L,Q; string S[1010]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); srand(time(NULL)); int b=rand()%(1<<30); dynamic_rolling_hash::set_base(b); cin>>N>>L>>Q; vector>RH; for(int i=0;i>S[i]; vectorv(L); for(int j=0;j(v)); } while(Q--) { int t; cin>>t; if(t==1) { int p; char c,d; cin>>p>>c>>d; p--; for(int i=0;i>T; vectorv; for(char c:T)v.push_back(int(c)); auto hashT=dynamic_rolling_hash(v).all_prod(); int ans=0; for(int i=0;i