#pragma GCC optmize(2,3,"Ofast","inline")
#include<bits/stdc++.h>
#define endl '\n'
typedef long long ll;
using namespace std;
ll tx,ty,a,b,q,x;
ll qpow(ll a,ll b){
if(b == -1)return 1;
if(b < -1)return 0;
ll ans = 1;
while(b){
if(b % 2 == 1)ans = ans * a % 998244353ll;
a = a * a % 998244353ll,b /= 2;
}
return ans;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> a >> b >> tx >> ty;
cin >> q;
while(q--){
cin >> x;
if(x == 1){
cout << 0 << " ";
continue;
}
if(qpow(a,(ll)(log(x * 1.0) * 1.0 / log(a * 1.0))) != x)cout << 0 << " ";
else cout << qpow(2,b - (ll)(log(x * 1.0) * 1.0 / log(a * 1.0)) - 1) << " ";
}
}
不知道为什么 WA on #11。