This page is still under construction.

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

Lexicographic Sorting

Time limit1sMemory limit1024 MB

Summary
Count subsets of the integers in [A, B] whose lexicographic order as strings matches their numerical order, modulo 1e9+7.
Level

Medium6 of 10

Topics
Sorting, String, Dynamic programming
Solved
No attempts yet

Problem

Mirek keeps several files of integers and had to sort the integers in each file in ascending order. He found a command line tool whose name was easy to guess and ran it. The tool treated every integer as a string and sorted the numbers lexicographically. Even so, the files came out in ascending numerical order, and that surprised him.

Say that the lexicographic and numerical orders of a set of integers agree when sorting the decimal representations of its elements as strings gives the same listing as sorting the elements by value. Equivalently, every two elements x<yx < y of the set satisfy that the string of xx comes before the string of yy lexicographically.

Strings are compared one character at a time, and when one string is a prefix of the other, the shorter one comes first. So 1 comes before 10, while 98 comes after 100.

Given the range [A,B][A, B], count the subsets of {A,A+1,…,B}\{A, A+1, \ldots, B\} whose lexicographic and numerical orders agree. The empty set and every subset with a single element satisfy the condition.

Input

The first and only line contains two integers AA and BB (1≤A≤B≤10181 \le A \le B \le 10^{18}, B−A≤105B - A \le 10^5).

Output

Print one integer MM on a single line, the number of subsets of {A,A+1,…,B}\{A, A+1, \ldots, B\} that satisfy the condition. The count can be very large, so print it modulo 109+710^9 + 7.

Hint

For A=98A = 98 and B=101B = 101 the subsets that satisfy the condition are ∅\emptyset, {98}\{98\}, {99}\{99\}, {100}\{100\}, {101}\{101\}, {98,99}\{98, 99\} and {100,101}\{100, 101\}.

Examples2

  1. Example 1

    Input
    98 101
    
    Expected output
    7
    
  2. Example 2

    Input
    1 9
    
    Expected output
    512