The decimal digits are divided into five colors and two states as follows.
Color | State | State |
|---|---|---|
Red | ||
Orange |
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.
The input is given from Standard Input in the following format:
For each test case, for in order, print on its own line the number of ordered pairs satisfying the conditions of the -th query.
Yellow |
Blue |
Purple |
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.
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.
Each case is given in the following format:
The -th query asks about the interval .
Do not print an additional separator between test cases.
| 2 | 60 | No additional constraints. |