#include using namespace std; vector anss; void expand(string str, int low, int high, auto &set) { // run till str[low.high] is a palindrome while (low >= 0 && high < str.length() && str[low] == str[high]) { // push all palindromes into the set set.insert(str.substr(low, high - low + 1)); // expand in both directions low--, high++; } } // Function to find all unique palindromic substrings of given string void allPalindromicSubstrings(string str) { // create an empty set to store all unique palindromic substrings unordered_set set; for (int i = 0; i < str.length(); i++) { // find all odd length palindrome with str[i] as mid point expand(str, i, i, set); // find all even length palindrome with str[i] and str[i+1] as // its mid points expand(str, i, i + 1, set); } // print all unique palindromic substrings for (auto i : set) anss.push_back(i.size()); //cout << i << " "; } int main() { string s; cin >> s; int q; cin >> q; for(int a0 = 0; a0 < q; a0++){ anss.resize(0); int l; int r; cin >> l >> r; s = s.substr(l-1,r-l+1); //cout<0;i--){ if(anss[i] == max)cnt++; else break; } cout << cnt%1000000007<< endl; } return 0; }