use proconio::input; fn main () { input! { t: u64, } for _ in 0..t { input! { n: u64, m: u64, } let d = n % (2*m); println!("{}", d % 998244353); } }