#include #define int long long using namespace std; int powmod(int a, int n, int mod) { if (n == 0) return 1; if (n % 2 == 0) return powmod((a * a) % mod, n / 2, mod); return (a * powmod(a, n - 1, mod)) % mod; } int mod = 998244353; signed main() { int t; cin >> t; while (t--) { int n, k; cin >> n >> k; //n (2^(nk) - 2^((n-1)k)) int res1 = powmod(2, n * k, mod); int res2 = powmod(2, (n - 1) * k, mod); int res3 = (res1 - res2 + mod) % mod; int ans = n * res3 % mod; cout << ans << endl; } return 0; }