#include using namespace std; using ll = long long; using pll = pair; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const ll MOD1000000007 = 1000000007; const ll MOD998244353 = 998244353; const ll MOD[3] = {999727999, 1070777777, 1000000007}; const ll LINF = 1LL << 60LL; const int IINF = (1 << 30) - 1; long long pow_mod(long long x, long long n, long long mod){ long long ret = 1; while(n > 0){ if(n & 1) ret = (ret*x)%mod; x = x*x%mod; n >>= 1; } return ret; } int l; //1-indexed ll sum(vector &bit, ll i, ll mod){ ll s = 0; while(i > 0){ s += bit[i]; s %= mod; i -= i & -i; } return s; } void add(vector &bit, ll i, ll x, ll mod){ while(i <= l){ bit[i] += x; bit[i] %= mod; i += i & -i; } } void solve(){ int n, q; cin >> n >> l >> q; vector> s(n, vector(l+1)); for(int i=0; i> s[i][j]; vector B(3); for(ll i=0; i<3; i++) B[i] = rng()%MOD[i]; vector> pow(3, vector(l+1, 1LL)); vector> invpow(3, vector(l+1, 1LL)); for(ll i=0; i<3; i++){ for(ll j=1; j<=l; j++){ pow[i][j] = pow[i][j-1]*B[i]%MOD[i]; invpow[i][j] = pow_mod(pow[i][j], MOD[i]-2, MOD[i]); } } vector> R(3, vector(26, 0LL)); for(ll i=0; i<3; i++){ for(ll j=0; j<26; j++) R[i][j] = rng()%MOD[i]; } //初期化 vector>> bit(n, vector>(3, vector(l+1, 0LL))); for(int i=0; i> type; if(type == 1){ int k; cin >> k; char c, d; cin >> c >> d; for(int i=0; i> t; int siz = (int)t.size(); vector hash(3, 0LL); for(int j=0; j<3; j++){ for(int k=0; k> T; while(T--) solve(); }