#include using namespace std; /*void initialize(string s) { // This function is called once before all queries. }*/ int answerQuery(int l, int r, string s){ char a[r-l+2]; int res=0; int i=0; for(l--;l0;res--) m*=res; return m; } return res*(i-2*res); // Return the answer for this query modulo 1000000007. } int main() { string s; cin >> s; //initialize(s); int q; cin >> q; for(int a0 = 0; a0 < q; a0++){ int l; int r; cin >> l >> r; int result = answerQuery(l, r, s); cout << result << endl; } return 0; }