#include using namespace std; string s; long long q,l,r,fix[100005][30]; long long f[30000002]; long long go(long long a,long long b ,long long c) { long long ans=1; while (b>0) { if (b%2==1) ans*=a; ans=ans%c; a*=a; a=a%c; b=b/2; } return ans; } int main() { cin>>s; for (int i=0; i>q; for (int i=1; i<=q; i++) { cin>>l>>r; l--; r--; int ans=0,k1=0,k2=0,K=1; if (l==0) { for (int j=0; j<26; j++) { if (fix[r][j]%2) k1++; k2+=fix[r][j]/2; K=(K*max(1ll,(f[fix[r][j]/2])))%1000000007; } } else for (int j=0; j<26; j++) { if ((fix[r][j]-fix[l-1][j])%2) k1++; k2+=(fix[r][j]-fix[l-1][j])/2; K=(K*(max(1ll,f[(fix[r][j]-fix[l-1][j])/2])%1000000007)%1000000007)%1000000007; } ans=((max(1ll,(f[k2]*go(K,1000000005,1000000007))%1000000007)%1000000007)*max(k1,1))%1000000007; cout<