Substring Inversion (Easy Version)
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

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:
  • is lexicographically greater than
Here, 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 ), or there exists such , that , and for any . Here denotes the length of the string a.
As the answer may be too big, please output the answer module .

输入描述:

The first line contains a single integer  --- the number of test cases.
The first line of each test case contains a single integer --- 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 over all test cases.

输出描述:

For each test case, output a single integer represents the answer module .
示例1

输入

复制
2
3
aab
3
aba

输出

复制
2
4