#include<bits/stdc++.h>
using namespace std;
int n,m,nn,a[10001][10001];
int cxk(int x,int y)
{
for(int i=0;i<=x;i++)a[i][0]=1;
for(int i=1;i<=x;i++)
for(int j=1;j<=y&&j<=i;j++)
a[i][j]=(a[i-1][j]+a[i-1][j-1])%998244353;
return a[x][y];
}
int main()
{
cin>>nn;
while(nn--)
{
cin>>n>>m;
cout<<cxk(n,m)<<endl;
}
return 0;
}