Pre - calculate prefix array
prefix = [ [ 0 for i in range ( 26 ) ] for i in range ( N ) ] NEW_LINE preCalculate ( s , prefix ) NEW_LINE queries = [ [ 1 , 4 ] , [ 3 , 4 ] ] NEW_LINE q = len ( queries ) NEW_LINE