×

- 58.53%
- 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:

Sum | Reward |
---|---|

6 | 10000 |

7 | 36 |

8 | 720 |

9 | 360 |

10 | 80 |

11 | 252 |

12 | 108 |

13 | 72 |

14 | 54 |

15 | 180 |

16 | 72 |

17 | 180 |

18 | 119 |

19 | 36 |

20 | 360 |

21 | 1080 |

22 | 144 |

23 | 1800 |

24 | 3600 |

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. )

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.

$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