This page is still under construction.

Parts of this page are still being built. What you see may change.

Rainbow Numbers

Time limit1sMemory limit512 MB

Summary
Count integers between two huge bounds (up to 100000 digits) whose decimal digits never repeat consecutively, modulo 998244353.
Level

Hard8 of 10

Topics
Dynamic programming, Math, Combinatorics, Implementation
Solved
No attempts yet

Problem

Define a rainbow number as an integer that, when written in base 1010 with no leading zeros, has no two adjacent digits equal.

Given a lower bound and an upper bound, count the rainbow numbers between them, inclusive.

Input

The first line contains a single integer LL (1≤L<101051 \le L < 10^{10^5}), the lower bound.

The second line contains a single integer UU (1≤U<101051 \le U < 10^{10^5}), the upper bound.

It is guaranteed that L≤UL \le U. The bounds are not a misprint; LL and UU can have up to 10510^5 digits.

Output

Print a single integer, the number of rainbow numbers between LL and UU inclusive. This number can be very large, so print it modulo 998 244 353998\,244\,353.

Examples2

  1. Example 1

    Input
    1
    10
    
    Expected output
    10
    
  2. Example 2

    Input
    12345
    65432
    
    Expected output
    35882