#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000000LL long long get(long long n,vector &sum){ long long res = 0; long long R = sum.size(); res = n/R * sum.back(); n %= R; res += sum[n]; return res; } int main(){ int R,N; cin>>R>>N; vector sum(R); rep(i,N){ int a; cin>>a; sum[a]++; } rep(i,R-1)sum[i+1] += sum[i]; int q; cin>>q; rep(_,q){ int l,r; cin>>l>>r; cout<