#include using namespace std; typedef long long ll; ll tousa(ll a,ll d,ll n){ return n*(2*a+(n-1)*d)/2; } ll s[32000],t[32000]; main(){ ll P; cin>>P; int sn,tn; sn=sqrt(P); tn=P/(sn+1); for(int i=1;i<=sn;++i){ s[i]=s[i-1]+P%i; } for(int i=1;i<=tn;++i){ t[i]=t[i-1]+tousa(P%(P/i),i,P/i-P/(i+1)); } int Q; cin>>Q; for(int i=0;i>L>>R; ll sum; if(P