#include using namespace std; constexpr int mod = 998244353; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while(t--) { long long n,x; cin >> n >> x; if(x%2 == 1) { cout << (n+1)/2%mod << "\n"; } else { if(n < x) { cout << (n+1)/2%mod << "\n"; } else { cout << (x/2+(n-x)/2+1)%mod << "\n"; } } } }