#include using namespace std; using ll = long long; mt19937_64 rng(time(0)); const ll B=1; ll MOD[B] = {998244353}; ll BASE[B] = {static_cast(rng() % MOD[0])}; //Rolling Hash on Segment Tree struct Record{ ll hash, pow; }; templatestruct SegTree { private: vector seg; int N = 1; int n; public: SegTree (ll n) : SegTree(vector(n, e())) {} SegTree (const vector &v){ n = v.size(); while (N < n) N *= 2; seg.resize(N*2-1, e()); for (ll i=0; i=0; i--) seg[i] = op(seg[i*2+1], seg[i*2+2]); } void set(int loc, S val){ loc += N-1; seg[loc] = val; while (loc != 0){ loc--; loc >>= 1; seg[loc] = op(seg[(loc<<1)+1], seg[(loc<<1)+2]); } } S prod (int l, int r) const{ l += N-1; r += N-1; S pl = e(), pr = e(); while(l<=r){ if (!(l & 1)){ pl = op(pl, seg[l]); l++; } if (r & 1){ pr = op(seg[r], pr); r--; } l--; r--; l >>= 1; r >>= 1; } return op(pl, pr); } S all_prod() const {return seg[0];} S get (int i) const {return seg[i+N-1];} }; using S = array; S op(S a, S b){ S res; for (int i=0; i> N >> L >> Q; vector s(N); vector> tree; auto to_hash=[&](string &s){ S x; int N=s.size(); vector v(N); for (int i=0; i(v); }; vector p(B, vector(L)); for (int i=0; i res(B); for (int i=0; i> 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> T; int ans=0; vector x = to_hash2(T); for (int i=0; i