Palindromic Deletions

아직 제출이 없습니다시간 제한30초메모리 제한1024 MB

문제

Games with words and strings are very popular lately. Now Edsger tries to create a similar new game of his own. Here is what he came up with so far.

Edsger's new game is called Palindromic Deletions. As a player of this game, you are given a string of length NN. Then you will perform the following process NN times:

  1. Pick an index in the current string uniformly at random.
  2. Delete the character at that index. You will then end up with a new string with one fewer character.
  3. If the new string is a palindrome, you eat a piece of candy in celebration.

Now Edsger wonders: given a starting string, what is the expected number of candies you will eat during the game?

입력

The first line of the input gives the number of test cases, TT. TT test cases follow. Each test case consists of two lines.

The first line of each test case contains an integer NN, representing the length of the string.

The second line of each test case contains a string SS of length NN, consisting of lowercase English characters.

출력

For each test case, output one line containing Case #x: E, where xx is the test case number (starting from 1) and EE is the expected number of candies you will eat during the game.

EE should be computed modulo the prime 109+710^9+7 (10000000071000000007) as follows. Represent the answer of a test case as an irreducible fraction pq\frac{p}{q}. The number EE then must satisfy the modular equation E×qp(mod(109+7))E×q≡p \pmod{(10^9+7)} , and be between 00 and 109+610^9+6, inclusive. It can be shown that under the constraints of this problem, such a number EE always exists and can be uniquely determined.

제한

  • 1T201≤T≤20.
  • String SS consists of only lowercase letters of the English alphabet.