Function to perform the queries
function performQueries ( L , R , K , n , q , tree ) { for ( let i = 0 ; i < q ; i ++ ) { document . write ( query ( tree , 1 , 0 , n - 1 , L [ i ] - 1 , R [ i ] - 1 , K [ i ] ) + " " ) ; } }