#include const int Mod = 998244353; long long memo[4001][4001] = {{1}}; int sum_memo[4001][4001] = {}; long long recursion(int x, int y) { if (memo[x][y] != 0) return memo[x][y]; if (x > 0) memo[x][y] += recursion(x - 1, y); if (y > 0) memo[x][y] += recursion(x, y - 1); if (x > 0 && y > 0) memo[x][y] += recursion(x - 1, y - 1) * 2; memo[x][y] %= Mod; return memo[x][y]; } int sum_recursion(int x, int y) { if (sum_memo[x][y] != 0) return sum_memo[x][y]; else sum_memo[x][y] = recursion(x, y); if (x > 0 && y > 0) sum_memo[x][y] += sum_recursion(x - 1, y - 1); if (sum_memo[x][y] >= Mod) sum_memo[x][y] -= Mod; return sum_memo[x][y]; } int main() { int i, Q, x, y; scanf("%d", &Q); for (i = 1; i <= Q; i++) { scanf("%d %d", &x, &y); printf("%d\n", sum_recursion(x, y)); } fflush(stdout); return 0; }