Permutation Fix Sum#12308

Permutation Fix Sum

5 seconds
256 megabytes
Hard

You're given a digital string of length , You're asked to evaluate f_1,f_2,f_3,...,f_n.

where

f_i=\sum_{ \displaystyle p \in \mathsf{dp}(s_1s_2...\mathbf{s_i}...s_n)} p

where denotes the set of distinct permutations.

and the bold color of \mathbf{s_i} means s_i is fixed and cannot be moved from index .

Since each of f_1,f_2,...,f_n may be incredibly large , print each modulo 10^9+7.

Input

The first line contains single integer (1 \le t \le 10^4) — the number of test cases.

The only line of test case contains single digital string (1 \le |s| \le 10^6) — the digital string.

It's guaranteed that \sum s \le 10^6 overall tests.

Output

For each test case , print integers f_1,f_2,...,f_n.

Examples

Example 1

Loading
Loading

Note

For the first test case:

For i=1 the distinct permutations are :

which gives f_1=101+110=211.

For i=2 the distinct permutations are :

which gives f_2=101

For i=3 the distinct permutations are :

which gives f_3=101+11=112

Scoring

  1. Subtask ( points) : (t=1; |s| \le 6)

  2. Subtask ( points) : (s_1=s_2=s_3=..=s_{|s|})

  3. Subtask ( points) : (s_i \neq s_j) for (i \neq j)

  4. Subtask ( points) : (1 \le \sum |s| \le 1000)

  5. Subtask ( points): No additional constraints.