#include using namespace std; #define pc putchar_unlocked #define gc getchar_unlocked typedef long long ll; typedef unsigned long long llu; #define mp make_pair #define pb push_back #define sc(x) scanf("%d",&x) #define sc2(x,y) scanf("%d%d",&x,&y) #define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z) #define scl(x) scanf("%lld",&x) #define scl2(x,y) scanf("%lld%lld",&x,&y) #define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z) #define scstr(x) scanf("%s",x) #define pd(x) printf("%d",x) #define pstr(x) printf("%s",x) #define newl() printf("\n") #define fl(i,n) for (i=0;i pii; typedef pair > piii ; typedef pair pll; typedef pair pli; #define gcd __gcd #define wl(n) while (n--) #define debug(x) cerr<<"debug->"<<#x<<"::"<>1,lc=(nod<<1),rc=(lc+1); btree(lc,a,mid); btree(rc,mid+1,b); tree[nod]=X(tree[lc]+tree[rc]); } int lo,hi; ll que(int nod ,int a,int b){ if(a>b||b>1,lc=(nod<<1),rc=(lc+1); if (lo<=a&&b<=hi) return tree[nod]; ll xx=que(lc,a,mid); ll yy=que(rc,mid+1,b); return X(xx+yy); } void upd(int nod,int a,int b,int ind) { if (a==b) { assert(a==ind); tree[nod]=X(X(X(C[a]*powd(inva,a+1,MOD))*powd(b,a,MOD))*(a%2==0?1:-1)); return ; } int mid=(a+b)>>1,lc=(nod<<1),rc=(lc+1); if (ind<=mid) upd(lc,a,mid,ind); else upd(rc,mid+1,b,ind); tree[nod]=X(tree[lc]+tree[rc]); } int main() { //ios::sync_with_stdio(0), cin.tie(0); scl3(n,a,b); scl(q); inva=powd(a,MOD-2,MOD); invb=powd(b,MOD-2,MOD); int i; for (i=0;i