#include //#include using namespace std; //using namespace atcoder; using ll = long long; //using mint = modint998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll R, N, Q, l, r; cin >> R >> N; vector A(N); for (int i=0; i> A[i]; sort(A.begin(), A.end()); cin >> Q; //[0,x]での答え auto f=[&](ll x){ ll res= x/R * N; res += upper_bound(A.begin(), A.end(), x%R)-A.begin(); return res; }; while(Q--){ cin >> l >> r; cout << f(r)-f(l-1) << endl; } return 0; }