from heapq import * from itertools import * from functools import * from collections import * import sys,math input = sys.stdin.readline mod = 998244353 def answer(): N,K = map(int,input().split()) print(N*(pow(2,N*K,mod) - pow(2,(N-1)*K,mod))%mod) for _ in range(int(input())): answer()