Task
The relative order string of a permutation is a string of characters from the set which is constructed in the following way:
For every :
- If , then .
- Otherwise, .
You are given an integer and two strings and consisting of characters from the set .
Find the number of permutations of length which satisfy both of the following conditions:
- The relative order string of is lexicographically greater than or equal to .
- The relative order string of is lexicographically less than or equal to .
Since the answer can be very large, print its remainder modulo .
Note: < is considered to be lexicographically smaller than >.
Input data
Each test contains multiple test cases. The first line of input contains a single integer () - the number of test cases. The next lines contain the descriptions of the test cases.
The first line of each test case contains a single integer () - the length of array .
The second line of each test case contains a string consisting of characters from the set .
The third line of each test case contains a string consisting of characters from the set .
It is guaranteed that, for all test cases, is lexicographically greater than or equal to . Additionally, it is guaranteed that the sum of across all test cases does not exceed .
Output data
For each test case, print the number of permutations of length whose relative order strings are lexicographically greater than or equal to and less than or equal to .
Since this number can be very large, print its remainder modulo .
Example
stdin
6
2
<
>
3
<>
<>
4
<<<
>><
4
<>>
><>
5
<><>
><><
15
<<<<<<>><<<<<>
<>><><><<><<<>
stdout
2
2
23
11
62
740226177
Explanation
In the first test case, both permutations of length have a relative order string which is lexicographically between < and >.
In the second test case, there are permutations whose relative order string is equal to <>: and .
In the third and fourth test cases, there are possible relative order strings:
<<<, which is the relative order string of permutation: .<<>, which is the relative order string of permutations: , and .<><, which is the relative order string of permutations: ,
, , and .<>>, which is the relative order string of permutations: ,
and .><<, which is the relative order string of permutations: ,
and .><>, which is the relative order string of permutations: , , , and .>><, which is the relative order string of permutations: , and .>>>, which is the relative order string of permutation: .
The number of permutations whose relative order strings are between <<< and >>< is equal to: .
The number of permutations whose relative order strings are between <>> and ><> is equal to: .