#include using namespace std; const int MAX = 10000000; const long long MOD = 998244353; struct mat{ array, 2> A; mat(){ A = {{{1, 0}, {0, 1}}}; } mat(long long a, long long b, long long c, long long d){ A = {{{a, b}, {c, d}}}; } array &operator [](int k){ return A[k]; } }; mat operator *(mat A, mat B){ mat ans; for (int i = 0; i < 2; i++){ for (int j = 0; j < 2; j++){ ans[i][j] = (A[i][0] * B[0][j] + A[i][1] * B[1][j]) % MOD; } } return ans; } mat matpow(mat A, long long N){ mat ans; while (N > 0){ if (N % 2 == 1){ ans = ans * A; } A = A * A; N /= 2; } return ans; } int main(){ int T; cin >> T; vector left(MAX + 1); for (int i = 0; i < MAX; i++){ left[i + 1] = mat(i * 2 + 2, i, 1, 0) * left[i]; } vector right(MAX + 1); for (int i = 0; i < MAX; i++){ right[i + 1] = right[i] * mat(i * 2 + 2, i + 1, 1, 0); } for (int i = 0; i < T; i++){ long long n, m; cin >> n >> m; if (n > m){ swap(n, m); } mat A(n * 2 + 1, n, 1, 0); mat ans = right[n] * matpow(A, m - n) * left[n]; cout << ans[0][0] << endl; } }