#include #include using namespace std; using ll = long long; const ll MOD = 998244353; ll solve() { ll N, M, L, R; cin >> N >> M >> L >> R; ll ans = (R - L + 1) % MOD; ans *= ((M - L) / (N - 1) + 1) % MOD; ans %= MOD; return ans; } int main() { int T; cin >> T; while(T--) solve(); return 0; }