import java.io.*; import java.util.*; /** * This submission uses dynamic programming. * Keep track of the number of ways for the first i digits where the last * digit is j. Additionally we use two more flags to identify whether we * have placed the first non-zero digit and whether or not the value is * less than the upper bound. * * @author Finn Lidbetter */ public class RainbowFinn { static long MOD = 998_244_353L; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String lo = br.readLine(); String hi = br.readLine(); long diff = solve(hi) - solve(lo); diff += 1; for (int i=1; i=MOD) { dp[i][j][k][1] %= MOD; } } } } } // 0 is not counted correctly. long sum = 1; for (int j=0; j<10; j++) { for (int k=0; k<2; k++) { sum += dp[n][j][k][1]; if (sum>=MOD) sum %= MOD; } } return sum; } }