传统题 1000ms 256MiB

Minesweeper

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Minesweeper is Libra's favourite game.

A mine-sweeper map can be expressed as an n×mn\times m 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 3×N3\times N 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 T(1T100)T(1\le T\le 100) --- the number of test cases.

Each test case consists of one string with length N(1N10000)N(1\le N\le 10000), consisting of numbers, representing that the grid has 3 rows and NN columns. The ii-th number in the string represents the number in row 2, column ii 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 109+710^9+7.

Samples

2
22
000
6
1

五一欢乐训练赛

未参加
状态
已结束
规则
ACM/ICPC
题目
6
开始于
2023-5-2 14:00
结束于
2023-5-2 18:00
持续时间
4 小时
主持人
参赛人数
6