Driver Code
let q = 3 ; let L = [ 2 , 2 , 24 ] ; let R = [ 5 , 2 , 28 ] ; let prefix = [ ] , suffix = [ ] ; precompute ( prefix , suffix ) ; for ( let i = 0 ; i < q ; i ++ ) { document . write ( query ( prefix , suffix , L [ i ] , R [ i ] ) + " " ) ; }