/* mod = 998244353 query = int(input()) dp = [] for i in range(2026): dp.append([0]*2026) dp[0][1] = 1 for i in range(2,2026): for j in range(2026): if j-1 >= 0 and j+1<2026: dp[j][i] = (dp[j-1][i-1]+dp[j+1][i-1])%mod elif j+1<2026: dp[j][i] = dp[j+1][i-1] else: dp[j][i] = dp[j-1][i-1] for _ in range(query): n,a = map(int,input().split()) ans = 0 for i in range(1,2026): if a % i == 0: ans = (ans+dp[i][n])%mod print(ans) */ #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); const int LIM = 2026; const int MOD = 998244353; // dp[j][i] matches original: first index = position j (0..2025), second = step/time i (0..2025) static int dp[LIM][LIM]; // initialize to 0 (static does it, but be explicit) for (int j = 0; j < LIM; ++j) for (int i = 0; i < LIM; ++i) dp[j][i] = 0; dp[0][1] = 1; for (int i = 2; i < LIM; ++i) { for (int j = 0; j < LIM; ++j) { if (j - 1 >= 0 && j + 1 < LIM) { dp[j][i] = ( (long long)dp[j-1][i-1] + dp[j+1][i-1] ) % MOD; } else if (j + 1 < LIM) { dp[j][i] = dp[j+1][i-1]; } else { // j-1 >= 0 must hold here (this is the case j == LIM-1) dp[j][i] = dp[j-1][i-1]; } } } int query; if (!(cin >> query)) return 0; while (query--) { int n; long long a; cin >> n >> a; // follow original logic: sum dp[i][n] for i = 1..2025 when a % i == 0 long long ans = 0; if (n >= LIM) { // Python version would raise IndexError for out-of-range n. // In contest inputs n is guaranteed to be within bounds; handle safely by printing 0. cout << 0 << '\n'; continue; } for (int i = 1; i < LIM; ++i) { if (a % i == 0) { ans += dp[i][n]; if (ans >= MOD) ans -= MOD; } } cout << (ans % MOD) << '\n'; } return 0; }