Universal Cup Judging System

Universal Cup

Time Limit: 2.5 s Memory Limit: 1024 MB Total points: 100
Statistics

Given a positive integer $n$, in each turn:

  1. Uniformly choose a digit $d$ from $n$ (in decimal representation).
  2. Update $n$ by setting $n\leftarrow n\cdot(d+1)$.

Calculate the expected number of turns it takes for $n$ to exceed $N$, modulo $998244353$.

Input

There are multiple test cases in a single test file.

The first line of the input contains a single integer $T$ ($1\le T\le 200$), indicating the number of the test cases.

For each test case, the first line of the input contains two integers $n$ and $N$ ($1\le n\le N\le 10^{18}$).

Output

For each test case, output a single line contains a single integer, indicating the answer.

It can be proved that the answer always exists.

Examples

Input 1

3
1 10
1 100
1 1000

Output 1

3
4
942786340

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.