This page is still under construction.

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

Interesting Ranges (Small)

Time limit5sMemory limit512 MB

Summary
Count subranges of [L, R] containing an even number of decimal palindromes, modulo 1000000007, for R up to 10^13.
Level

Medium7 of 10

Topics
Math, Combinatorics, Binary search, Prefix sum
Solved
No attempts yet

Problem

A positive integer is a palindrome if its decimal representation, written without leading zeros, reads the same forwards and backwards. For example, 5, 77, 363, 4884, 11111, 12121 and 349943 are palindromes.

A range of integers is interesting if it contains an even number of palindromes. For L≤RL \le R, the range [L,R][L, R] is the sequence of integers from LL to RR inclusive, that is (L,L+1,L+2,…,R−1,R)(L, L+1, L+2, \dots, R-1, R), and LL and RR are its first and last numbers. Zero is even, so a range that contains no palindrome at all is also interesting.

The range [L1,R1][L_1, R_1] is a subrange of [L,R][L, R] if L≤L1≤R1≤RL \le L_1 \le R_1 \le R. Determine how many subranges of [L,R][L, R] are interesting.

Input

The first line contains the number of test cases TT. Each of the next TT lines describes one test case and contains two positive integers LL and RR, in that order, separated by a single space.

Limits

  • 1≤T≤1201 \le T \le 120
  • 1≤L≤R≤10131 \le L \le R \le 10^{13}

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 1 and yy is the number of interesting subranges of [L,R][L, R] modulo 10000000071000000007.

Examples2

  1. Example 1

    Input
    3
    1 2
    1 7
    12 110
    
    Expected output
    Case #1: 1
    Case #2: 12
    Case #3: 2466
    
  2. Example 2

    Input
    5
    1 1
    10 10
    11 11
    9 10
    1 3
    
    Expected output
    Case #1: 0
    Case #2: 1
    Case #3: 0
    Case #4: 1
    Case #5: 2