A Function to answer the Queries
static void queryResults ( String str , Query q [ ] , int m , int n , int prefix [ ] , int suffix [ ] , int power [ ] ) { for ( int i = 0 ; i <= m - 1 ; i ++ ) { int L = q [ i ] . L ; int R = q [ i ] . R ;