#!/bin/python3 import sys def initialize(s): # This function is called once before all queries. pass def answerQuery(l, r): # Return the answer for this query modulo 1000000007. mennyi = 0 betuk = list(s[l-1:r]) print(betuk) return mennyi % 1000000007 if __name__ == "__main__": s = input().strip() initialize(s) q = int(input().strip()) for a0 in range(q): l, r = input().strip().split(' ') l, r = [int(l), int(r)] result = answerQuery(l, r) print(result)