MOD = 998244353 N = 4000 A = [[0] * N for _ in range(N)] for i in range(N): A[0][i] = 5 + 3 * i A[i][0] = 5 + 3 * i for i in range(1, N): for j in range(1, N): A[i][j] = A[i - 1][j] + A[i][j - 1] + 2 * A[i - 1][j - 1] if i == j: A[i][j] += 1 A[i][j] %= MOD Q = int(input()) for _ in range(Q): x, y = map(int, input().split()) print(A[x - 1][y - 1])