#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ll long long

void IO(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int MOD = 1e9 + 7;
const int N = 5e3 ;

vector<vector<int>> dp ( N , vector<int>(N));

string s ;
void solve(int tc) {

    cin >> s;
    int n = s.size() ;
    int q; cin >> q;


    vector<vector<int>> pal ( n , vector<int>( n ));
    for (int l = n -1 ; l>=0 ; l -- ) {
        for (int r = l ; r <n ; r ++ ) {
            if ( l == r ) {
                pal[l][r]=1 ;
            }
            else {
                pal[l][r] = s[l] == s[r] && pal[l + 1][r-1] ;
            }
        }
    }

    while ( q -- ) {
        int l, r ; cin >> l >> r ;
    }





}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    IO();

    int TC = 1;
    // cin >> TC;

    for (int i = 1; i <= TC; i++) {
        solve(i);
    }

    return 0;
}