#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T1,class T2> bool cmin(T1 &x,const T2 &y) { if (y<x) { x=y; return 1; }return 0; }
template<class T1,class T2> bool cmax(T1 &x,const T2 &y) { if (x<y) { x=y; return 1; }return 0; }
#define all(x) (x).begin(),(x).end()
const int mod=998244353;
ll power(ll a,ll p)
{
ll ret=1;
while (p)
{
if (p&1)
ret=ret*a%mod;
a=a*a%mod;
p>>=1;
}
return ret;
}
ll inv(ll n)
{
return power(n,mod-2);
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
int n,x,y,q;
while (cin>>n>>x>>y>>q)
{
vector<pair<int,int>> qs(q);
int A=0,B=0;
for (auto &[a,b]:qs)
{
cmax(A,a);
cmax(B,b);
}
map<ll,vector<vector<ll>>> F;
function<void(ll)> solve=[&](ll len)
{
if (F.find(len)!=F.end())
return;
solve(len>>1);
solve(len+1>>1);
auto &fl=F[len>>1],&fr=F[len+1>>1];
vector<vector<ll>> f(A+1,vector<ll>(B+1,0ll));
if (len==1)
{
f[1][0]=f[0][1]=1;
F[len]=f;
return;
}
vector<int> C1(max(A,B)+1,0);
C1[0]=1;
for (int i=1; i<=max(A,B); i++)
{
C1[i]=C1[i-1]*((len>>1)-i+1)%mod*inv(i)%mod;
}
vector<int> C2=C1;
for (int i=1; i<=max(A,B); i++)
{
C1[i]=C1[i-1]*((len+1>>1)-i+1)%mod*inv(i)%mod;
}
for (int i=0; i<=A; i++)
{
for (int j=0; j<=B; j++)
{
for (int k=0; k<=j; k++)
{
(f[i][j]+=C2[j-k]*fl[i][k])%=mod;
}
}
}
for (int i=0; i<=B; i++)
{
for (int j=0; j<=A; j++)
{
for (int k=0; k<=j; k++)
{
(f[j][i]+=C1[j-k]*fr[k][i])%=mod;
}
}
}
F[len]=f;
return;
};
solve(n);
auto &out=F[n];
for (auto [x,y]:qs)
{
cout<<out[x][y]<<'\n';
}
}
}