# 计蒜客

1. 题库
2. Cacti Lottery
3. 问答
• 58.01%
• 2000ms
• 262144K

Morgana is playing a game called cacti lottery. In this game, morgana has a $3 \times 3$ grid graph, and the graph is filled with $1$ ~ $9$ , each number appears only once. The game is interesting, he doesn't know some numbers, but there are also some numbers he knows but don't want to tell you.

Now he should choose three grids, these three grids should be in the same column or in the same row or in the diagonal line. Only after this choice, can he know all numbers in the grid graph. Then he sums the three numbers in the grids he chooses, get the reward as follows:

SumReward
610000
736
8720
9360
1080
11252
12108
1372
1454
15180
1672
17180
18119
1936
20360
211080
22144
231800
243600

Then he wants you to predict the expected reward he will get if he is clever enough in the condition that he doesn't want to tell you something he knows.

("He is clever enough" means he will choose the max expected reward row or column or dianonal in the condition that he knows some numbers. And you know that he knows some number, but you don't know what they are exactly. So you should predict his expected reward in your opinion. )

### Input

First line contains one integers $T$ ($T \le 100$) represents the number of test cases.

Then each cases contains three lines, giving the $3 \times 3$ grid graph. '*' means Morgana knows but doesn't want to tell you, '#' means Morgana doesn't know, '0' ~ '9' means the public number that Morgana and you both know.

### Output

$T$ lines, output the answer. If the answer is $A$, and your answer is $B$. Your answer will be considered as correct if and only if $|(A-B)| < 1e-5$ .

#### 样例输入

2
123
***
###
12*
45#
78#

#### 样例输出

10000
4313.16666667

• main.c