

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.typecons;
  
  int x, k;
  rd(x); rd(k);
  auto r=readln.split.to!(int[]);
  int q; rd(q);
  Tuple!(int, int)[] qs;
  foreach(_; 0..q){
    int t, a; rd(t, a);
    qs~=tuple(t, a);
  }

  alias Q=Tuple!(int, "t", int, "a");
  Q[] queries;
  foreach(t; r) queries~=Q(t, -1);
  foreach(e; qs) queries~=Q(e[0], e[1]);
  sort(queries);

  int l=0, u=x;
  int j=0, p=0;
  int d=0, f=-1;
  foreach(e; queries){
    int dd=(e.t-p)*f;
    u=min(x, max(0, u+dd));
    l=max(0, min(x, l+dd));
    d+=dd; p=e.t;
    if(e.a==-1){
      f*=-1;
    }else{
      int y=e.a+d;
      writeln(min(u, max(l, y)));
    }
  }


}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}