#include using namespace std; using ll= long long; using ull=unsigned long long; using ldo =long double; #define rep(i,n,k) for(ll i = k; i < (ll)(n); i++) templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b>N>>M>>P>>Q; rep(i,Q,0){ cin>>x>>f; now=f; ans=0; while(now/x<=M){ if(now%x==0)ans++; now+=P; } cout<