output_description: For each query, print the answer in its own line.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      X
      K
      r_1 r_2 .. r_K
      Q
      t_1 a_1
      t_2 a_2
      :
      t_Q a_Q
attempt: # coding: utf-8
  def II():
      return int(input())
  
  
  def ILI():
      return list(map(int, input().split()))
  
  
  def read():
      X = II()
      K = II()
      r = ILI()
      Q = II()
      queries = [ILI() for __ in range(Q)]
      return X, K, r, Q, queries
  
  
  def solve(X, K, r, Q, queries):
      l_ans = []
      r.insert(0, 0)
      dif_r = [r[i + 1] - r[i] for i in range(K)]
      for i in range(K):
          if i % 2 == 1:
              dif_r[i] = -dif_r[i]
      print(dif_r)
      # dif_r.append(10 ** 9)
      for query in queries:
          t, a = query
          dif_r_ind = 0
          now_state = 0
          now_time = 0
          ans = a
          while True:
              if now_time + dif_r[dif_r_ind] > t:
                  if now_state == 1:
                      ans += t - now_time
                      ans = min(X, ans)
                  else:
                      ans -= t - now_time
                      ans = max(0, ans)
                  break
              else:
                  if now_state == 1:
                      ans += dif_r[dif_r_ind]
                      ans = min(X, ans)
                  else:
                      ans -= dif_r[dif_r_ind]
                      ans = max(0, ans)
                  now_time += dif_r[dif_r_ind]
                  now_state = (now_state + 1) % 2
                  dif_r_ind += 1
                  continue
          l_ans.append(ans)
      ans = "\n".join(map(str, l_ans))
      return ans
  
  
  def main():
      params = read()
      print(solve(*params))
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs
  contain some amount of sand. When we put the sandglass, either bulb A or B
  lies on top of the other and becomes the _upper bulb_. The other bulb becomes
  the _lower bulb_.
  
  The sand drops from the upper bulb to the lower bulb at a rate of 1 gram per
  second. When the upper bulb no longer contains any sand, nothing happens.
  
  Initially at time 0, bulb A is the upper bulb and contains a grams of sand;
  bulb B contains X-a grams of sand (for a total of X grams).
  
  We will turn over the sandglass at time r_1,r_2,..,r_K. Assume that this is an
  instantaneous action and takes no time. Here, time t refer to the time t
  seconds after time 0.
  
  You are given Q queries. Each query is in the form of (t_i,a_i). For each
  query, assume that a=a_i and find the amount of sand that would be contained
  in bulb A at time t_i.
samples: [{"input": "180\n    3\n    60 120 180\n    3\n    30 90\n    61 1\n    180 180", "output": "60\n    1\n    120\n    \n\nIn the first query, 30 out of the initial 90 grams of sand will drop from bulb\nA, resulting in 60 grams. In the second query, the initial 1 gram of sand will\ndrop from bulb A, and nothing will happen for the next 59 seconds. Then, we\nwill turn over the sandglass, and 1 second after this, bulb A contains 1 gram\nof sand at the time in question.\n\n* * *"}, {"input": "100\n    1\n    100000\n    4\n    0 100\n    90 100\n    100 100\n    101 100", "output": "100\n    10\n    0\n    0\n    \n\nIn every query, the upper bulb initially contains 100 grams, and the question\nin time comes before we turn over the sandglass.\n\n* * *"}, {"input": "100\n    5\n    48 141 231 314 425\n    7\n    0 19\n    50 98\n    143 30\n    231 55\n    342 0\n    365 100\n    600 10", "output": "19\n    52\n    91\n    10\n    58\n    42\n    100"}]