import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static void initialize(String str) { int max = 1; int start = 0; int len = str.length(); int low, high; for (int i = 1; i < len; ++i) { low = i - 1; high = i; while (low >= 0 && high < len && str.charAt(low) == str.charAt(high)) { if (high - low + 1 > max) { start = low; max = high - low + 1; } --low; ++high; } low = i - 1; high = i + 1; while (low >= 0 && high < len && str.charAt(low) == str.charAt(high)) { if (high - low + 1 > max) { start = low; max = high - low + 1; } --low; ++high; } } for( int i = start; i <= start+max-1; ++i ) System.out.print(2); } /*static int answerQuery(int l, int r) { // Return the answer for this query modulo 1000000007. }*/ public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.next(); initialize(s); int q = in.nextInt(); for(int a0 = 0; a0 < q; a0++){ int l = in.nextInt(); int r = in.nextInt(); initialize(s); } in.close(); } }