Function to solve all the queries
function solve ( n , q ) { let qu = [ 5 , 3 , 6 ] ; seg_tree = new Array ( 4 * n + 1 ) ; seg_tree . fill ( 0 ) ; build_tree ( 1 , 0 , n - 1 ) ; for ( let i = 0 ; i < qu . length ; i ++ ) { document . write ( qu [ i ] + " " ) ; } for ( let i = q ; i < q ; i ++ ) {