#583
Unrated
Pair Programming
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

A program consists of a sequence of instructions, each of which is of one of the following forms:

×d\times d, where dd is a digit in the range [0,9]$$+s, where ss is a string denoting the name of a variable. Within a program, all variable names must be distinct.

The result of executing a program is defined to be the expression that results after applying each instruction in order, starting with 00. For example, the result of executing the program [×3,+x,+y,×2,+z][\times 3,+x,+y,\times 2,+z] is the expression (0×3+x+y)×2+z=2×x+2×y+z(0\times 3+x+y)\times 2+z=2\times x+2\times y+z. Different programs, when executed may produce the same expressions; for example, executing [+w,×0,+y,+x,×2,+z,×1][+w,\times 0,+y,+x,\times 2,+z, \times 1] would also result in the expression 2×x+2×y+z2\times x+2\times y+z.

Bessie and Elsie each have programs of NN (1N20001\le N\le 2000) instructions. They will interleave these programs to produce a new program of length 2N2N. Note that there are (2N)!N!×N!\frac{(2N)!}{N!\times N!} ways to do this, but not all such programs, when executed, will produce distinct expressions.

Count the number of distinct expressions that may be produced by executing Bessie and Elsie's interleaved program, modulo 109+710^9+7.

Each input contains TT (1T101\le T\le 10) test cases that should be solved independently. It is guaranteed that the sum of NN over all test cases does not exceed 20002000.

입력

The first line of the input contains TT, the number of test cases.

The first line of each test case contains NN.

The second line of each test case contains Bessie's program, represented by a string of length NN. Each character is either a digit d[0,9]d\in [0,9], representing an instruction of type 1, or the character ++, representing an instruction of type 2.

The third line of each test case contains Elsie's program in the same format as Bessie's.

Within a test case, the variable names among all instructions are distinct. Note that their actual names are not provided, as they do not affect the answer.

출력

The number of distinct expressions that may be produced by executing Bessie and Elsie's interleaved programs, modulo 109+710^9+7.

예제 입력 1

4
1
0
1
3
12+
+02
3
0++
++9
4
5+++
+6+1

예제 출력 1

1
3
9
9

점수

Input 2 satisfies N6N\le 6.In inputs 3-5, the sum of all NN is at most 100100.In inputs 6-8, the sum of all NN is at most 500500.Inputs 9-16 satisfy no additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.