{"problem":{"name":"Two Kinds of Base","description":{"content":"For a non-negative integer sequence $S=(S_1,S_2,\\dots,S_k)$ and an integer $a$, we define the function $f(S,a)$ as follows: *   $f(S,a) = \\sum_{i=1}^{k} S_i \\times a^{k - i}$. For example, $f((1,2,3","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc322_g"},"statements":[{"statement_type":"Markdown","content":"For a non-negative integer sequence $S=(S_1,S_2,\\dots,S_k)$ and an integer $a$, we define the function $f(S,a)$ as follows:\n\n*   $f(S,a) = \\sum_{i=1}^{k} S_i \\times a^{k - i}$.\n\nFor example, $f((1,2,3),4) = 1 \\times 4^2 + 2 \\times 4^1 + 3 \\times 4^0 = 27$, and $f((1,1,1,1),10) = 1 \\times 10^3 + 1 \\times 10^2 + 1 \\times 10^1 + 1 \\times 10^0 = 1111$.\nYou are given positive integers $N$ and $X$. Find the number, modulo $998244353$, of triples $(S,a,b)$ of a sequence of non-negative integers $S=(S_1,S_2,\\dots,S_k)$ and positive integers $a$ and $b$ that satisfy all of the following conditions.\n\n*   $k \\ge 1$\n*   $a,b \\le N$\n*   $S_1 \\neq 0$\n*   $S_i < \\min(10,a,b)(1 \\le i \\le k)$\n*   $f(S,a) - f(S,b) = X$\n\n## Constraints\n\n*   $1 \\le N \\le 10^9$\n*   $1 \\le X \\le 2 \\times 10^5$\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $X$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc322_g","tags":[],"sample_group":[["4 2","5\n\nThe five triples $(S,a,b)=((1,0),4,2),((1,1),4,2),((2,0),4,3),((2,1),4,3),((2,2),4,3)$ satisfy the conditions."],["9 30","31"],["322322322 200000","140058961"]],"created_at":"2026-03-03 11:01:14"}}