#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int R, n; cin >> R >> n; vector a(n); for(auto &&v : a) cin >> v; sort(a.begin(), a.end()); int Q; cin >> Q; while(Q--){ int l, r; cin >> l >> r; int pl = l / R, pr = r / R; l %= R, r %= R; ll L = lower_bound(a.begin(), a.end(), l) - a.begin(); ll R = upper_bound(a.begin(), a.end(), r) - a.begin(); L += pl * (ll)(n), R += pr * (ll)(n); cout << R - L << '\n'; } }