/****************************************** * AUTHOR: CHIRAG AGARWAL * * INSTITUITION: BITS PILANI, PILANI * ******************************************/ #include using namespace std; typedef long long LL; typedef long double LD; const int MAX=1e5+5; const int MOD=1e9+7; long long powera[MAX]; long long powerb[MAX]; long long prod[MAX]; long long segt[4*MAX]; long long arr[MAX]; typedef long long LL; int add(int a, int b, int c) { int res = a + b; return (res >= c ? res - c : res); } int mod_neg(int a, int b, int c) { int res; if(abs(a-b) < c) res = a - b; else res = (a-b) % c; return (res < 0 ? res + c : res); } int mul(int a, int b, int c) { LL res = (LL)a * b; return (res >= c ? res % c : res); } template T power(T e, T n, T m) { T x = 1, p = e; while(n) { if(n & 1) x = mul(x, p, m); p = mul(p, p, m); n >>= 1; } return x; } template T extended_euclid(T a, T b, T &x, T &y) { T xx = 0, yy = 1; y = 0; x = 1; while(b) { T q = a / b, t = b; b = a % b; a = t; t = xx; xx = x - q * xx; x = t; t = yy; yy = y - q * yy; y = t; } return a; } template T mod_inverse(T a, T n) { T x, y, z = 0; T d = extended_euclid(a, n, x, y); return (d > 1 ? -1 : mod_neg(x, z, n)); } void build(int pos,int l,int r) { if(l==r) { segt[pos]=arr[l]; //printf("%d %d cam\n ",arr[l],pos); return; } int mid=(r+l)/2; build(pos+pos,l,mid); build(pos+pos+1,mid+1,r); segt[pos]=(segt[pos+pos]+(((segt[pos+pos+1])*(prod[mid-l+1]))%MOD))%MOD; //printf("%lld %d\n",segt[pos],pos); } void update(int pos,int l,int r,int ind,int val) { if(l>ind||rqr||rqr) { return 0ll; } if(l>=ql&&r<=qr) { return segt[pos]; } int mid=(l+r)/2; long long q1=query(pos+pos,l,mid,ql,qr); long long q2=query(pos+pos+1,mid+1,r,ql,qr); q2=(q2*prod[mid-l+1])%MOD; return ((q1+q2)%MOD); } int main() { int n,q,a,b; scanf("%d %d %d %d",&n,&a,&b,&q); b=(MOD-b); powera[0]=powerb[0]=prod[0]=1; for(int i=1;i