Welcome to ZOJ
Information
Select Problem
Runs
Ranklist
ZOJ Problem Set - 3697
Bad-written Number

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Description

A little kid loves to write digits in LC display style, but he would like to put two consecutive digits very close to each other. Sometimes, that makes the number he writes ambiguous.

In LC display style, each digit is written as below:

0 1 2 3 4 5 6 7 8 9
 _ 
| |
|_|

   
  |
  |

 _ 
 _|
|_ 

 _ 
 _|
 _|


|_|
  |

 _ 
|_ 
 _|

 _ 
|_ 
|_|

 _ 
  |
  |

 _ 
|_|
|_|

 _ 
|_|
 _|

As the table shown above, in LC display style, each digit is written in 3 rows and 3 columns. The little kid always overlaps the last column of the previous digit and the first column of the next digit.

Please help his parents to count the number of different ways to translate the weird 'image'.

Input

There are multiple test cases. The first line of input contains an integer T (T ≤ 1500) indicating the number of test cases. Then T test cases follow.

The first line of each case contains one integer: n (n ≤ 104) -- the number of digits that the little kid writes.

Then each of the following 3 lines contains exactly 2n+1 characters -- represents the number written by the kid.

Output

For each test case, print a single number -- the number of ways to express the bad-written 'image' module 109+7 (which is equivalent to print answer % 1000000007, where % is the module operator in all major programming languages).

Sample Input

6
1
   
|  
|  
1
 _ 
|_|
|_ 
1

  |
  |
1
 _
|_|
|_|
2
   _ 
  |_|
  |_|
2
 _ _ 
 _|_ 
|_ _|

Sample Output

0
0
1
1
3
1

Hint

Sometimes, the little kid may make some mistakes, in which case you should output 0. It's forbidden to miss anything or change the character's position (it should be exactly the same as the table shown above). So the answers of the first two cases are 0s. The third case can be translated in 3 ways: 13, 18, 19.
Author: OUYANG, Jialin
Contest: The 13th Zhejiang University Programming Contest
Submit    Status