class SegmentTree def initialize(v) @n = 1 while @n < v.length do @n *= 2 end @node = Array.new(2*@n-1, 0) v.each_with_index{|x, i| @node[i+@n-1] = x } (@n-2).downto(0) {|i| @node[i] = @node[2*i+1] ^ @node[2*i+2] } end def query(a, b, k=0, l=0, r=@n) if r <= a or b <= l then return 0 end if a <= l and r <= b then return @node[k] else vl = query(a, b, k * 2 + 1, l, (l + r) / 2) vr = query(a, b, k * 2 + 2, (l + r) / 2, r) return vl ^ vr end end end N, Q = gets.split(" ").map{|s| s.to_i} a = gets.split(" ").map{|s| s.to_i} q = [] Q.times { q << gets.split(" ").map(&:to_i) } st = SegmentTree.new(a) ans = [] q.each {|l, r| ans << st.query(l-1, r) } puts ans