The decimal digits are divided into five colors and two states as follows.
Color | State | State |
|---|---|---|
Red | ||
Orange | ||
Yellow | ||
Blue | ||
Purple |
The five colors are placed on a cycle in the following order.
Define the composition of two colors as follows. Start at color . Move in the direction of the arrows by the number of steps needed to move from Red to color . The color at which you arrive is the composition result.
For example, Yellow is two steps from Red, so composing Orange with Yellow gives Blue, which is two steps after Orange.
For two one-digit decimal numbers , define their weird decimal XOR as follows.
- The color of the result is the composition of the colors of and .
- The state of the result is the bitwise XOR of the states of and .
For example, is Orange with state , while is Blue with state . Composing Orange and Blue gives Purple, and , so .
Extend the operation to nonnegative integers with multiple decimal digits. A missing higher digit is treated as . The weird decimal XOR of two integers is obtained by independently applying the one-digit operation at every decimal position.
For example, the tens digit satisfies and the ones digit satisfies , so .
When the operation is applied more than once, evaluate it from left to right. Thus,
You are given a sequence . Each query consists of two integers . For each query, count the ordered pairs of integers satisfying both conditions below.
- .
- .
Input
The input is given from Standard Input in the following format:
Each case is given in the following format:
The -th query asks about the interval .
Output
For each test case, for in order, print on its own line the number of ordered pairs satisfying the conditions of the -th query.
Do not print an additional separator between test cases.
Constraints
- .
- .
- The sum of over all test cases does not exceed .
- The sum of over all test cases does not exceed .
- ().
- ().
- Every number in the input is an integer.