#include using namespace std; #include using namespace atcoder; using ll=long long; using Graph=vector>; #define INF 1000000000 #define MOD 998244353 #define MAX 1000000 string X,Y; int dfs(int i,int R,char c,vector &length,vector> &cnt,vector> &sumX,vector> &sumY){ if(i==1){ return sumX[c-'a'][R]; } if(R<=length[i-1]){ return dfs(i-1,R,c,length,cnt,sumX,sumY); } if(R<=length[i-1]+(int)Y.size()){ return cnt[c-'a'][i-1]+sumY[c-'a'][R-length[i-1]]; } return 2*cnt[c-'a'][i-1]+sumY[c-'a'][Y.size()]-dfs(i-1,2*length[i-1]+(int)Y.size()-R,c,length,cnt,sumX,sumY); } int main(){ int Q; cin>>X>>Y>>Q; vector> sumY(26,vector(Y.size()+1,0)); vector> sumX(26,vector(X.size()+1,0)); for(int j=0;j length(33); vector> cnt(26,vector(33,0)); length[1]=X.size(); for(int j=0;j<26;j++){ cnt[j][1]=sumX[j][X.size()]; } for(int i=2;i<33;i++){ length[i]=2*length[i-1]+(int)Y.size(); if(length[i]>INF){ length[i]=INF; } for(int j=0;j<26;j++){ cnt[j][i]=2*cnt[j][i-1]+sumY[j][Y.size()]; if(cnt[j][i]>INF){ cnt[j][i]=INF; } } } for(int i=0;i>L>>R>>C; cout<len(F[n-1])+len(Y) }