#include #define _ ios_base::sync_with_stdio(false);cin.tie(0); using namespace std; #define pb push_back #define pob pop_back #define pf push_front #define pof pop_front #define mp make_pair #define all(a) a.begin(),a.end() #define bitcnt(x) __builtin_popcountll(x) #define MOD 1000000007 #define PI 3.14159265 #define tot 300005 #define BLOCK 20000 #define MAXN 1000000000000000 typedef unsigned long long int uint64; typedef long long int int64; int poly[100005]; int64 powe(int64 a,int64 b){ int64 ret=1; while(b){ if(b&1){ ret=ret*a; if(ret>MOD) ret%=MOD; } else{ a=a*a; if(a>MOD) a%=MOD; } b/=2; } return ret; } int64 a,b; bool chck(int l,int r){ int64 prev=0; for(int i=r;i>=l;i--){ int64 val=poly[i]-prev; if(val<0) val+=MOD; if(val%a==0){ int64 mul=val/a; prev=mul*b; if(prev>MOD) prev%=MOD; } int add; for(add=0;add<=10;add++){ val+=MOD; if(val%a==0){ int64 mul=val/a; prev=mul*b; if(prev>MOD) prev%=MOD; break; } } if(add>10) return false; } if(prev) return false; return true; } int main(){ int n,q; cin>>n>>a>>b>>q; for(int i=0;i