X = gets.chomp.to_i
K = gets.chomp.to_i
r = gets.chomp.split(' ').map(&:to_i)
Q = gets.chomp.to_i
query = []
Q.times do
  query << gets.chomp.split(' ').map(&:to_i)
end

query.each_with_index do |q, i|
  last = q[1]
  prevR = 0
  r.each.with_index(1) do |rk, index|
    s = index % 2 == 0 ? 1 : -1
    if q[0] <= rk
      p last + s*(q[0] - prevR)
      break
    else
      last = last + s*(rk - prevR)
      last = 0 if last < 0
      last = X if last > X
      prevR = rk
    end
  end
end