题号:NC244824
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld
题目描述
Lucy and Vega are playing a game named Guess The Number .
In this game , Lucy selects a decimal number

randomly , then converts

into base

(We call them

,

,

,

,

).
Such as :

, then
_2)
,
_3)
,
_5)
,
_7)
,
_%7B11%7D)
( here

means

in decimal ) .
Lucy defines

as the

-th
)
digit of

,

uses the same method .
Such as :
_2)
,
Then for each

in range

( inclusive ) , Lucy gets

( in decimal ) .
After that , Lucy tells

to Vega , and Vega needs to guess the number

.
Please help Vega to find what

is . If there are multiple answers , tell Vega the minimum one .
输入描述:
The first line contains an integer
(
, indicates the number of test cases .
Then
lines follows : Each line has exactly
non-negative numbers
, separated by space .
输出描述:
For each case , Print an integer : the minimum answer
in one line . We guarantee
.
示例1
输入
复制
1
6 9 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
说明
In this case ,
,
.