import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static String inputWord; static void initialize(String s) { // This function is called once before all queries. inputWord = s; } static int answerQuery(int l, int r) { // Return the answer for this query modulo 1000000007. int maxNum = 0; int numEven; Map charFreq = new HashMap<>(); String availableString = inputWord.substring(l-1,r-1); char[] characters = availableString.toCharArray(); for(int i = 0; i < characters.length; i++){ if(!charFreq.containsKey(characters[i])){ charFreq.put(characters[i], 1); }else{ charFreq.put(characters[i], charFreq.get(characters[i])+1); //numEven++; not sure yet if even amount must look afterwards } } for(Integer num: charFreq.keySet()){ } return maxNum%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(); int result = answerQuery(l, r); System.out.println(result); } in.close(); } }