MOD = 998244353 def f(n,k): return (n*(pow(2,k,MOD)-1)*pow(2,k*(n-1),MOD))%MOD T = int(input()) for _ in range(T): N,K = map(int,input().split()) print(f(N,K))