#include using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; template using V=vector; template using VV=V>; const int MOD=998244353; const ll m2=499122177; ll f(ll x){ x%=MOD; return x*(x+1)%MOD*m2%MOD; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; cin>>t; while(t--){ ll n,a; cin>>n>>a; if(a==1){ cout<