#include using namespace std; #define mm 1000000007 #define half 50001 vector > count_to_here; vector fact(half); int len; unsigned long long inv(int i){ if (i<2) return i; int exp = mm - 2; unsigned long long pow = i; unsigned long long ret = 1; while (exp){ if (exp & 1){ ret = (ret * pow) % mm; } pow = (pow*pow) % mm; exp >>= 1; } return ret; } void initialize(string s) { // This function is called once before all queries. len = s.size(); count_to_here.resize(len+1, vector(26,0)); for (int i = 1; i<= len; i++){ count_to_here[i] = count_to_here[i-1]; count_to_here[i][s[i-1]-'a']++; } fact[0] = 1; for (int i=1; i>= 1; det = (det * fact[tmp]) % mm; sum += tmp; } unsigned long long ret = (fact[sum] * inv(det)) % mm; return ((remain > 1) ? ( (ret * remain)%mm ) : ret); } 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); cout << result << endl; } return 0; }