J. Substring Inversion (Easy Version)
time limit per test
3 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

This is the easy version of the problem. The only difference between the two versions is the constraint on $$$n$$$.

Given a string $$$s$$$ of length $$$n$$$ consisting of lowercase letters only, please calculate the number of 4-tuples $$$(a,b,c,d)$$$ satisfying following conditions:

  • $$$1\le a\le b\le n$$$
  • $$$1\le c\le d\le n$$$
  • $$$a \lt c$$$
  • $$$s[a:b]$$$ is lexicographically greater than $$$s[c:d]$$$
Here, $$$s[i:j]$$$ represents a substring of $$$s$$$ which start from the $$$i$$$-th character and end at $$$j$$$-th character(inclusive).

String $$$x$$$ is lexicographically less than string $$$y$$$, if either $$$x$$$ is a prefix of $$$y$$$ (and $$$x \ne y$$$), or there exists such $$$i(1 \le i \le min(|x|, |y|))$$$, that $$$x_i \lt y_i$$$, and for any $$$j(1\le j \lt i), x_j = y_j$$$. Here $$$|a|$$$ denotes the length of the string $$$a$$$.

As the answer may be too big, please output the answer module $$$10^9+7$$$.

Input

The first line contains a single integer $$$T(1\le T \le 10)$$$ — the number of test cases.

The first line of each test case contains a single integer $$$n(1\le n \le 400)$$$ — the length of the string.

The second line of each test case contains a string $$$s$$$ of length $$$n$$$ consisting of lowercase letters only.

It is guaranteed that $$$\sum{n} \le 400$$$ over all test cases.

Output

For each test case, output a single integer represents the answer module $$$10^9+7$$$.

Example
Input
2
3
aab
3
aba
Output
2
4