Guess The Number
题号: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 P randomly , then converts P into base 2,3,5,7,11 (We call them A,B,C,D,E).

Such as :

, then , , , , ( here A means 10 in decimal ) .

Lucy defines A_i as the i-th digit of A , B_i,C_i,D_i,E_i uses the same method .

Such as :

,

Then for each i in range ( inclusive ) , Lucy gets ( in decimal ) .

After that , Lucy tells to Vega , and Vega needs to guess the number P .

Please help Vega to find what P is . If there are multiple answers , tell Vega the minimum one .

输入描述:

The first line contains an integer T ( , indicates the number of test cases .

Then T lines follows : Each line has exactly 37 non-negative numbers , separated by space .

输出描述:

For each case , Print an integer : the minimum answer P 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

输出

复制
15

说明

In this case , P=15,A=(1111)_2,B=(0120)_3,C=(0030)_5,D=(0021)_7,E=(0014)_{11} , 

F_0=(1+0+0+1+4)=6,F_1=1+2+3+2+1=9,F_2=1+1+0+0+0=2,F_3=1+0+0+0+0=1 .