{"problem":{"name":"Variety of Digits","description":{"content":"Given are $M$ digits $C_i$. Find the sum, modulo $998244353$, of all integers between $1$ and $N$ (inclusive) that contain all of $C_1, \\ldots, C_M$ when written in base $10$ without unnecessary leadi","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc235_f"},"statements":[{"statement_type":"Markdown","content":"Given are $M$ digits $C_i$.\nFind the sum, modulo $998244353$, of all integers between $1$ and $N$ (inclusive) that contain all of $C_1, \\ldots, C_M$ when written in base $10$ without unnecessary leading zeros.\n\n## Constraints\n\n*   $1 \\leq N < 10^{10^4}$\n*   $1 \\leq M \\leq 10$\n*   $0 \\leq C_1 < \\ldots < C_M \\leq 9$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$M$\n$C_1$ $\\ldots$ $C_M$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc235_f","tags":[],"sample_group":[["104\n2\n0 1","520\n\nBetween $1$ and $104$, there are six integers that contain both `0` and `1` when written in base $10$: $10,100,101,102,103,104$.  \nThe sum of them is $520$."],["999\n4\n1 2 3 4","0\n\nBetween $1$ and $999$, no integer contains all of `1`, `2`, `3`, `4`."],["1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n5\n0 2 4 6 8","397365274\n\nBe sure to find the sum modulo $998244353$."]],"created_at":"2026-03-03 11:01:14"}}