#P9930. [NFLSPC #6] 1064 病毒

[NFLSPC #6] 1064 病毒

Background

Your computer has been infected with the 1064 virus, and now all numbers stored on your computer have started to collapse.

To destroy your computer more thoroughly, for an nn-digit number in decimal, the evil 1064 virus will iterate it by some rule at least n+1n + 1 times, to make sure you cannot recover it.

Facing the 1064 virus, you are at a loss. But as an OIer, you want to know dao dao dao dao dao dao dao dao dao dao dao dao dao dao dao dao dao.

Problem Description

A digit string is defined as a string that contains only digits 090\sim 9. Odd digits are 1,3,5,7,91, 3, 5, 7, 9, and even digits are 0,2,4,6,80, 2, 4, 6, 8.

For a digit string xx, let the numbers of odd digits, even digits, and total digits in it be a,b,ca, b, c, respectively. Then a+b=c=xa + b = c = |x|. Define g(x)g(x) as the digit string obtained by writing a,b,ca, b, c in order, without ignoring leading zeros. For example, g(0)=011g(\texttt{0}) = \texttt {011}, g(1064)=134g(\texttt{1064}) = \texttt{134}, g(822)=033g(\texttt {822}) = \texttt {033}, g(1092515503)=7310g(\texttt{1092515503}) = \texttt{7310}.

Let fk(x)f_k(x) denote: first write the number xx into a digit string xx' ignoring leading zeros, then iterate g(x)g(x') for kk times, and take the number represented by the resulting digit string. That is, let x=g(g(g(x)))x ^ * = g(g(\cdots g(x'))) (there are kk applications of gg), then fk(x)f_k(x) is the result of converting xx ^ * into a number.

Given n,kn, k (guaranteed n<kn < k), compute i=010n1fk(i)\sum_{i = 0} ^ {10 ^ n - 1} f_k(i).

There are multiple test cases.

Input Format

The first line contains an integer TT.

The next TT lines each contain two integers n,kn, k, representing one test case.

Output Format

For each test case, output one integer per line, representing the answer.

1
0 1

11

Hint

For all testdata, 1T601\leq T\leq 60, 0n<k1050\leq n < k \leq 10 ^ 5, k105\sum k\leq 10 ^ 5.

  • Subtask 1 (3030 points): n5n\leq 5, k15k\leq 15.
  • Subtask 2 (7070 points): no special constraints.

Source: NFLSPC #6 F by Alex_Wei

Translated by ChatGPT 5