Minesweeper
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Description
Minesweeper is Libra's favourite game.
A mine-sweeper map can be expressed as an grid. Each cell of the grid is either a mine cell or a non-mine cell. A mine cell has no number on it. Each non-mine cell has a number representing the number of mine cells around it.
Now, Libra and Rahn are playing mine-sweeper on a grid, where all cells in row 2 are no-mine cells. And they have got the number on each cell in row 2.
Libra and Rahn want to find out the number of ways to set the mines in row 1 and row 3 vaildly.
Format
Input
The first line contains one integer --- the number of test cases.
Each test case consists of one string with length , consisting of numbers, representing that the grid has 3 rows and columns. The -th number in the string represents the number in row 2, column of the grid.
Output
For each test case, print a single number representing the answer. Since the answer may be large, you need to print the answer modulo .
Samples
2
22
000
6
1