Prefix array to store the XOR values from array elements
let prefix = new Array ( n ) ; let x = 0 ; for ( let i = 0 ; i < n ; i ++ ) { x ^= arr [ i ] ; prefix [ i ] = x ; } for ( let i = 0 ; i < m ; i ++ ) { queryResult ( prefix , Q [ i ] ) ; } }