Thunder Bitz

Jul 2, 2021

1 min read

Chef vs Bharat Solution | CHEFORA |CODECHEF JULY CHALLENGE

Codechef

View problem on codechef

Chef and his friend Bharat have decided to play the game “The Chefora Spell”.

In the game, a positive integer NN (in decimal system) is considered a “Chefora” if the number of digits dd is odd and it satisfies the equationN=∑i=0d−1Ni⋅10i,N=∑i=0d−1Ni⋅10i,

where NiNi is the ii-th digit of NN from the left in 00-based indexing.

Let AiAi denote the ii-th largest Chefora number.

They’ll ask each other QQ questions, where each question contains two integers LL and RR. The opponent then has to answer with(∏i=L+1R(AL)Ai)mod109+7.(∏i=L+1R(AL)Ai)mod109+7.

Bharat has answered all the questions right, and now it is Chef’s turn. But since Chef fears that he could get some questions wrong, you have come to his rescue!

Input

- The first line contains an integer QQ — the number of questions Bharat asks.

- Each of the next QQ lines contains two integers LL and RR.

Output

Print QQ integers — the answers to the questions on separate lines.

Constraints

- 1≤N,Q≤1051≤N,Q≤105

- 1≤L